Question 14

AQA Computer Science June 2022 Paper 1 (7517/1)A level13 marks

On the specification

14.1
4.1 Fundamentals of programming3.1 Fundamentals of programming
14.2
3.3 Systematic approach to problem solving
Question text

14 This question adds a new type of difficulty card to the game, a trap. When the player draws a trap card from the deck, it works as follows: • if no challenges from the current lock have been met, the trap card works in the same way as a difficulty card and the player’s choice to lose a key or discard five cards is executed • if one or more challenges from the current lock have been met, one of the met challenges is randomly chosen and has its status changed so it is no longer met. This happens instead of executing the player’s choice to lose a key or discard five cards from the deck. Trap cards are used in the game instead of difficulty cards when the player chooses to load a game from a file. They are not used when the player chooses to play a new game. What you need to do Task 1 Create a new class called TrapCard that is a subclass of the DifficultyCard class. The constructor for this new class should set the value of CardNumber to the value of the constructor’s parameter and set the value of CardType to Trp. Create a subroutine Process in the TrapCard class that overrides the subroutine from the DifficultyCard class and allows a trap card to work in the way described. Task 2 Modify the SetupCardCollectionFromGameFile subroutine in the Breakthrough class so that it creates TrapCards instead of DifficultyCards. Task 3 Modify the GetCardFromDeck subroutine in the Breakthrough class so that if the top card of the deck has a CardType of Trp, that card is treated in the same way as if the top card of the deck had a CardType of Dif. When the top card of the deck has a CardType of Trp, the message "Trap!" should be displayed. Task 4 Test that the changes you have made work: • run the Skeleton Program • enter L • enter U • enter 1 • enter P • enter U • enter 1 • enter P • enter D Evidence that you need to provide Include the following evidence in your Electronic Answer Document. 14.1 Your PROGRAM SOURCE CODE for the amended subroutine GetCardFromDeck, the amended subroutine SetupCardCollectionFromGameFile and the new class TrapCard. [12 marks] 14.2 SCREEN CAPTURE(S) showing the requested test. [1 mark]