Question 14

AQA Computer Science November 2021 Paper 1 (7517/1)A level9 marks

On the specification

14.1
3.1 Fundamentals of programming
14.2
3.3 Systematic approach to problem solving
Question text

14 This question extends the Skeleton Program by adding a new command to the game that allows a player to burn lumber to turn it into fuel. If a player uses the burn command when they have lumber in their supply a random integer between one and the amount of lumber they have in their supply is generated. The amount of lumber in their supply is decreased by this random integer with the amount of fuel in their supply being increased by the same amount. If a player uses the burn command when they do not have any lumber in their supply the message Cannot burn lumber is displayed and no fuel is created. What you need to do Task 1 Modify the CheckCommandIsValid subroutine so that it returns True if the command was burn. Task 2 Modify the ExecuteCommand subroutine in the HexGrid class so that when a player chooses the burn command it returns the string Cannot burn lumber if the player does not have any lumber in their supply. If the player does have lumber in their supply it: • generates a random integer between one and the amount of lumber in the player’s supply • decreases the amount of lumber in the player’s supply by the random number generated • increases the amount of fuel in the player’s supply by the random number generated • returns the string Command executed. Task 3 Test that the changes you have made work: • run the Skeleton Program • choose the default game • enter the command burn • press the Enter key twice. Evidence that you need to provide Include the following evidence in your Electronic Answer Document. 14.1 Your PROGRAM SOURCE CODE for the amended subroutines CheckCommandIsValid and ExecuteCommand. [8 marks] 14.2 SCREEN CAPTURE(S) showing the requested test. [1 mark]