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

5 marks
 * 1) Write an explanation of how makePlayerMove works below

2. Within the final else statement in makePlayerMove, the player is told “Hit at” position if they have hit an enemy ship. Modify the code within this else statement so that it also outputs the name of the ship that they have hit. 4 marks 3 marks

3. The board stores the first character from the ship name to represent which ship is stored in a square. Create a new function called outputHit. It must return a String and take two parameters, a character called square and an array of Ship called ships. It must loop through each item in the array until it finds the name of the ship that matches the square character and then return the name of that ship. You will need to modify the output code in makePlayerMove so that it passes in the pointer to the ships array and the board[row][column] value and outputs the string that is returned by the function. 8 marks 2 marks

3 marks