Question 9

AQA Computer Science Specimen Paper 1 (7517/1)A level10 marks

On the specification

9.1
4.1 Fundamentals of programming
9.2
3.3 Systematic approach to problem solving
Question text

9 This question will extend the functionality of the game. The game is to be altered so that there is a new type of enemy: a sleepy enemy. A sleepy enemy is exactly the same as a normal enemy, except that after making four moves it falls asleep again. Task 1 Create a new class called SleepyEnemy that inherits from the Enemy class. Task 2 Create a new integer attribute in the SleepyEnemy class called MovesTillSleep. Task 3 Create a new public subroutine in the SleepyEnemy class called ChangeSleepStatus. This subroutine should override the ChangeSleepStatus subroutine from the Enemy class. The value of MovesTillSleep should be set to 4 in this subroutine. Task 4 Create a new public subroutine in the SleepyEnemy class called MakeMove. This subroutine should override the MakeMove subroutine from the Enemy class. When called this subroutine should reduce the value of MovesTillSleep by 1 and then send the monster to sleep if MovesTillSleep has become equal to 0. Task 5 Modify the Game class so that the Monster object is of type SleepyEnemy (instead of Enemy). Task 6 Check that the changes you have made work by conducting the following test: • play the training game • move east • move east • move south. Evidence that you need to provide Include the following in your Electronic Answer Document. 9.1 Your PROGRAM SOURCE CODE for the new SleepyEnemy class. [8 marks] 9.2 SCREEN CAPTURE(S) showing the requested test. [2 marks]