Question 8 2016 · May-June · Paper 43 · 13 marks
Reveal official mark-scheme answer
Official answer for Question 8
Question 1
Show text version of question
Question 8
Question 15
The programmer decides to use a 2D array to represent the board. The index numbering to be used is as shown.
Each square on the board is either occupied by one piece only, or is empty.
The data stored in the array indicate whether or not that square is occupied, and if so, with a black piece or a white piece.
(i)
Write program code to initialise the contents of the array to represent the board at the
start of the game. Use characters as follows for each square:
'B' represents a black piece 'W' represents a white piece 'E' represents an empty square
Visual Basic and Pascal: You should include the declaration statements for variables. Python: You should show a comment statement for each variable used with its data type.
Programming language .....................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[4]
Question 16
(ii)
When a piece is to be moved, a procedure will calculate and output the possible
destination squares for the moving piece.
This will be a move:
- either to an empty square, with no occupied squares on the way
- or to a square containing a piece belonging to another player, with no occupied
squares on the way. The other player’s piece is then removed.
For example, for the circled black piece there are nine possible destination squares. Each of the two destination squares contains a white piece which would be removed.
x y 1 2 3 4 5 6 7 8 The program requires a procedure ValidMoves.
Question 1
2 It needs three parameters:
3 • PieceColour – colour of the moving piece
- xCurrent – current x position
4 • yCurrent – current y position 5 The procedure will calculate all possible destination squares in the x direction only.
Question 6
Question 7
Question 8
Example output for the circled black piece is:
Possible moves are: Moving LEFT 3 4 2 4 REMOVE piece Moving RIGHT 5 4 6 4 7 4
Write program code for procedure ValidMoves with the following procedure header:
PROCEDURE ValidMoves(PieceColour : CHAR, xCurrent : INTEGER, yCurrent : INTEGER).
Question 17
Visual Basic and Pascal: You should include the declaration statements for variables. Python: You should show a comment statement for each variable used with its data type.
Programming language .....................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
Question 18
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[5]
Question 19
Part (c)
The problem is well suited to an object-oriented design followed by object-oriented
programming.
(i)
Describe how classes and objects could be used in this problem.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
.......................................................................................................................................[2]
(ii)
For a class you identified in part(c)(i), state two properties and two methods.
Class ..............................................
Properties
1 ........................................................................................................................................
2 ........................................................................................................................................
Methods
1 ........................................................................................................................................
2 ........................................................................................................................................
Question 20
effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the publisher will be pleased to make amends at the earliest possible opportunity.
To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge International Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after the live examination series.
Cambridge International Examinations is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of University of Cambridge Local Examinations Syndicate (UCLES), which is itself a department of the University of Cambridge.
Why this question appears here
98% assigned-topic match · Further programming › Programming paradigms
Topic-match percentages estimate how closely each question fits the selected syllabus topic. They are a guide for choosing stricter or broader practice.
Permanent source page: Educate A Change · From 9608_s16_qp_43.pdf
