Skip to main content
A-LevelComputer ScienceFurther programming9618/41 · May/June 2022 · Q225 Marks

A computer game is being developed using object-oriented programming. One element of the game is a balloon. This is designed as the class Balloon. The class has the following attributes and methods. Balloon Health : INTEGER The health of the balloon Colour : STRING The colour of the balloon DefenceItem : STRING The item the balloon uses to defend itself Constructor() Initialises the defence item and colour using the parameters Initialises health to 100 ChangeHealth() Takes the change as a parameter and adds this to the health GetDefenceItem() Returns the defence item of the object CheckHealth() If the health is 0 or less, it returns TRUE, otherwise it returns FALSE

  1. (a)The constructor takes the name of the defence item and the balloon's colour as parameters and sets these to the attributes. The health is initialised to 100. Write program code to declare the class Balloon and its constructor. Do not write any other methods. Use your language appropriate constructor. All attributes should be private. If you are writing in Python include attribute declarations using comments. Save your program as Question2_J2022. Copy and paste the program code into part 2(a) in the evidence document.[5]
  2. (b)The get method GetDefenceItem() returns the defence item of the object. Amend your program code to include the get method GetDefenceItem(). Save your program. Copy and paste the program code into part 2(b) in the evidence document.[2]
  3. (c)The object's method ChangeHealth() takes an integer number as a parameter and adds this to the health attribute of the object. Amend your program code to include the method ChangeHealth(). Save your program. Copy and paste the program code into part 2(c) in the evidence document.[2]
  4. (d)The object's method CheckHealth() returns TRUE if the health of the object is 0 or less (no health remaining) and returns FALSE otherwise (health remaining). Amend your program code to include the method CheckHealth(). Save your program. Copy and paste the program code into part 2(d) in the evidence document.[2]
  5. (e)Amend the main program to: • take as input a defence item and colour from the user • create a new balloon with the identifier Balloon1 using the data input. Save your program. Copy and paste the program code into part 2(e) in the evidence document.[3]
  6. (f)The function Defend(): • takes a balloon object as a parameter • takes as input the strength of an opponent from the user • uses the ChangeHealth() method to subtract the strength input from the object's health • outputs the defence item of the balloon • checks the health of the object and outputs an appropriate message if it has no health remaining, or if it has health remaining • returns the amended balloon object. Write program code to declare the function Defend(). Save your program. Copy and paste the program code into part 2(f) in the evidence document.[8]
  7. (g)(i)Amend the main program to call the function Defend(). Save your program. Copy and paste the program code into part 2(g)(i) in the evidence document.[2]
  8. (g)(ii)Test your program using the following inputs: • balloon defence method "Shield" • balloon colour "Red" • strength of opponent 50 Take a screenshot to show the output. Copy and paste the screenshot into part 2(g)(ii) in the evidence document.[1]

Mark scheme

Marking points from the official mark scheme (May/June 2022). The mark or mark type is shown in brackets.

  1. [1] Class Balloon declaration (and end where appropriate)
  2. [1] declaration of 3 attributes as private with suitable data types
  3. [1] constructor header (and end) with two parameters
  4. [1] ... initialising colour and defence item to parameters
  5. [1] initialising health to 100
  6. [1] get header and close with no parameter ...
  7. [1] returning defence item attribute
  8. [1] procedure header and close taking 1 parameter ...
  9. [1] adding parameter value to health attribute
  10. [1] method header and close and checking if health attribute is <= 0
  11. [1] Returning TRUE if health attribute <= 0 and returning FALSE otherwise
  12. [1] take as input defence method and colour (2 strings)
  13. [1] instantiating new balloon object with identifier Balloon1
  14. [1] ... with both input values as parameters
  15. [1] function header (and end where appropriate) and taking balloon object as parameter
  16. [1] Inputting strength
  17. [1] Calling ChangeHealth method for the parameter object ...
  18. [1] ... with the input as a subtraction
  19. [1] outputting the defence item for the parameter object ...
  20. [1] ... using GetDefenceItem()
  21. [1] Calling CheckHealth() for the parameter object ...
  22. [1] outputting appropriate message if TRUE is returned (no health remaining)
  23. [1] outputting appropriate message if FALSE is returned (health remaining).
  24. [1] Returning the updated balloon object
  25. [1] calling Defend with balloon object ...
  26. [1] ... and stores return value over object
  27. [1] 1 mark for screenshot with: Shield, Red and 50 input Output stating their defence item was Shield Output says health is not 0 (in some manner)

Write your answer and get it marked

On Oracle Prep you can write or photograph your own answer and have it marked by AI against this mark scheme, with feedback on what you missed.

Sign up free →

About this question

Topic
Further programming, A-Level Computer Science (syllabus 9618). Structured question, 25 marks.
Source
A-Level Computer Science, May/June 2022 Paper 4 Variant 1, question 2.

Questions and mark schemes are from past examination papers and remain the copyright of the exam board. How Oracle Prep builds its content

Related Computer Science questions

© 2026 Oracle Prep