Question 9
AQA Computer Science June 2017 Paper 1A level5 marks
On the specification
- 9.1
- 3.1 Fundamentals of programming
- 9.2
- 4.13 Systematic approach to problem solving
Question text
9 This question refers to the subroutine InputCoordinate in the Simulation class. The warren and fox inspection options in the Skeleton Program do not currently check if the coordinates entered by the user are on the landscape. This behaviour needs to be improved so that an error message is displayed if the user inputs coordinates for a location that is not on the landscape. If the user runs a simulation with default settings then the landscape size is 15, so valid locations have an x coordinate between 0 and 14, inclusive. What you need to do Modify the InputCoordinate subroutine in the Simulation class so that, if a coordinate outside the range defined by the landscape size is input, the error message "Coordinate is outside of landscape, please try again." is displayed and the user is forced to re-input the coordinate. To achieve full marks for this question, the InputCoordinate subroutine should work correctly for any landscape size, not just the default size of 15. Test Test your changes work by running the Skeleton Program and selecting the following options: • "1. Run simulation with default settings" • "3. Inspect fox" Then input these three x coordinates for the location of the fox to inspect: • -1 • 15 • 0 Evidence that you need to provide Include the following in your Electronic Answer Document. 9.1 Your PROGRAM SOURCE CODE for the amended subroutine InputCoordinate. [4 marks] 9.2 SCREEN CAPTURE(S) for the described test. Ensure that in your SCREEN CAPTURE(S) it can be seen that the x coordinates -1 and 15 are rejected and that the x coordinate 0 is accepted, and that after the 0 is input the Skeleton Program advances to ask the user to input the y coordinate. [1 mark]