A-level Computing/AQA/Problem Solving, Programming, Data Representation and Practical Exercise/Skeleton code/2016 Exam/Sample Question Papers/June 2016 Practice Questions 3

1. Within the subroutine printBoard there is a conditional statement which is extremely long and not dynamic. Explain in the box below why it is not dynamic and in what situations it may not work correctly. The statement is shown below:- (board[row][column] == 'A' || board[row][column] == 'B' || board[row][column] == 'S' || board[row][column] == 'D' || board[row][column] == 'P') 2 marks

2. Rewrite the statement within printBoard to make it work dynamically.

4 marks 3 mark

3. Within the subroutine checkWin there is a conditional statement which is the same as the one within printBoard. If you were to just copy your dynamic statement from printBoard to replace this it would not work. Explain why below:-

2 marks

4. Rewrite the statement within checkWin to make it work dynamically.

4 mark

5. Add another ship with a size of 1 and the name “Row Boat” to the appropriate subroutine 2 marks

6. In order to make use of your additional ship, there is another change you must make to the program code. Make that change.

1 mark

7. In order to test your code, you need to be able to see the positions of the ships on the board. To do this, there is a change you must make to the line console.print(" "); within the subroutine printBoard. Comment out this line of code (DO NOT DELETE IT) and add an alternate line below it that will display the actual character stored within the board array instead of an empty space. 4 marks

2 marks

8. So that the game performs as it used to, comment out your additional line of code and remove the comments from the line console.print(" ");

1 mark

1 mark