Question 12
AQA Computer Science June 2017 Paper 1A level12 marks
On the specification
- 12.1
- 3.1 Fundamentals of programming4.2 Fundamentals of data structures
- 12.2
- 3.1 Fundamentals of programming
- 12.3
- 4.13 Systematic approach to problem solving
Question text
12 The landscape affects the foxes’ ability to eat the rabbits. Foxes do not like to swim, so will not cross the rivers on the landscape to eat. If a river lies between a fox and a warren, the fox will not eat any rabbits in the warren, even if it is near enough for it to do so. As the rivers only run horizontally and vertically, and extend from one side of the landscape to the other, a simple way to check if reaching a warren would require a fox to cross a river is to: • Calculate the coordinates of all of the locations between the fox and the warren in a horizontal line, level with the fox. • Calculate the coordinates of all of the locations between the fox and the warren in a vertical line, level with the fox. • If any of the locations horizontally or vertically between the fox and the warren contain a river, then the fox will not eat any of the rabbits in the warren as the fox’s path to the warren crosses a river. Figure 15 shows the locations that would need to be checked to see if fox F could eat any rabbits in warren W. The locations that need to be checked are shown in black and the rivers are shown in grey. As location (5, 7) contains part of a river, the fox would not eat any rabbits in this warren. Figure 15 1 2 3 4 5 6 7 8 9 10 11 12 13 14 0 1 2 3 4 W 5 6 7 F 8 9 10 11 12 13 14 If you have not been able to fully complete Question 11, you will still be able to get most of the marks for this question if you can correctly compute the coordinates of the locations that would need to be checked to see if a river was present. To get full marks for this question, your solution must work regardless of whether a warren is above, below, to the left or to the right of a fox. What you need to do Task 1 Create a new subroutine CheckIfPathCrossesRiver, in the Simulation class, that takes the coordinates of two locations in the landscape and checks if there is a river between them. Task 2 Modify the FoxesEatRabbitsInWarren subroutine in the Simulation class so that it calls the CheckIfPathCrossesRiver subroutine, and ensures that if there is a river between a fox and a warren then the fox will not eat any rabbits from the warren. Test Check that the changes you have made work by conducting the following test: • Select option "1. Run simulation with default settings" from the main menu. • Then select option "1. Advance to next time period showing detail". When the test is conducted, no rabbits in the warren at (1, 1) should be eaten as it is bounded by rivers on all sides. Evidence that you need to provide Include the following in your Electronic Answer Document. 12.1 Your PROGRAM SOURCE CODE for the new subroutine CheckIfPathCrossesRiver from the Simulation class. [9 marks] 12.2 Your PROGRAM SOURCE CODE for the amended subroutine FoxesEatRabbitsInWarren from the Simulation class. [2 marks] 12.3 SCREEN CAPTURE(S) for the described test. Your SCREEN CAPTURE(S) only needs to show what happens in the warren at location (1, 1) when the simulation advances to the next time period. It should contain similar information to Figure 16 below, but the exact number of rabbits killed, dying of old age and other details may differ owing to the random nature of parts of the simulation. [1 mark] Figure 16