Question 13
AQA Computer Science November 2021 Paper 1 (7517/1)A level8 marks
On the specification
- 13.1
- 4.1 Fundamentals of programming
- 13.2
- 3.3 Systematic approach to problem solving
Question text
13 This question adds a new type of piece to the game, a ranger, that moves differently to the other pieces. A ranger can move in the same way as a standard (serf) piece but can also move directly to any available forest tile in the grid if the ranger is currently in a forest tile. The cost of making this type of move is one fuel. What you need to do Task 1 Create a new class called RangerPiece that is a subclass of the Piece class. The constructor for this new class should make a call to the constructor of the Piece class and then set the value of PieceType to R. Task 2 Create a subroutine CheckMoveIsValid in the new RangerPiece class that overrides the subroutine from the base class and allows a ranger piece to move in the way described. Task 3 Modify the subroutine AddPiece in the HexGrid class so that it creates a new RangerPiece if TypeOfPiece is Ranger. Task 4 Modify the subroutine SetupDefaultGame so that Player One has a ranger piece in tile 8 instead of a serf piece. Task 5 Test that the changes you have made work: • run the Skeleton Program • choose the default game • enter the command move 8 12 • enter the command move 12 2 • enter the command move 2 3 • then press the Enter key so that the grid is displayed showing the results of these commands. Evidence that you need to provide Include the following evidence in your Electronic Answer Document. 13.1 Your PROGRAM SOURCE CODE for the new class RangerPiece and the amended subroutine AddPiece. [7 marks] 13.2 SCREEN CAPTURE(S) showing the requested test. [1 mark]