Question 2(b)(ii) 2023 · May-June · Paper 41 · 4 marks
Reveal official mark-scheme answer
Official answer for Question 2
Part (b)
(ii)
Question 1
mark each to max 4
Question 4
Show text version of question
Question 2
Part (b)
(ii)
Question 2
A computer game is being designed that will include different vehicles. A prototype for the game is
being developed using object‑oriented programming.
The class Vehicle stores data about the vehicles. Each vehicle has an identification name, a maximum speed, a current speed and a horizontal position. The value IncreaseAmount is added to the current speed each time the vehicle increases its speed.
Vehicle ID : STRING stores the identification name for the vehicle
MaxSpeed : INTEGER stores the maximum speed
CurrentSpeed : INTEGER stores the current speed
IncreaseAmount : INTEGER stores the amount CurrentSpeed increases by
HorizontalPosition : INTEGER stores the horizontal position Constructor() initialises ID, MaxSpeed and IncreaseAmount to the parameter values initialises both CurrentSpeed and HorizontalPosition to 0
GetCurrentSpeed() returns the current speed
GetIncreaseAmount() returns the increase amount
GetHorizontalPosition() returns the horizontal position
GetMaxSpeed() returns the maximum speed
SetCurrentSpeed() assigns the parameter to the current speed
SetHorizontalPosition() assigns the parameter to the horizontal position
IncreaseSpeed() calculates and stores the new speed and horizontal position of the vehicle The child class Helicopter inherits from the parent class Vehicle. A helicopter also has a vertical position and changes the vertical position when it increases speed.
Helicopter VerticalPosition : INTEGER stores the vertical position
VerticalChange : INTEGER stores the amount VerticalPosition changes by
MaxHeight : INTEGER stores the maximum height the helicopter can reach Constructor() takes the ID, maximum speed, increase amount, vertical change and maximum height as parameters initialises the vertical position to 0
GetVerticalPosition() returns the vertical position
IncreaseSpeed() changes the current speed, horizontal and vertical position of the helicopter
(ii)
The Helicopter method IncreaseSpeed() overrides the method from the parent
class and:
- adds the amount of vertical change to the vertical position
- adds IncreaseAmount to the current speed
- adds the updated current speed to the horizontal position.
The vertical position of a helicopter cannot exceed its maximum height.
The current speed of a helicopter cannot exceed its maximum speed.
Write program code for the method IncreaseSpeed()
Save your program.
Copy and paste the program code into part 2(b)(ii) in the evidence document.
Question 7
Why this question appears here
82% assigned-topic match · Programming › Constructs
Topic-match percentages estimate how closely each question fits the selected syllabus topic. They are a guide for choosing stricter or broader practice.
Permanent source page: Educate A Change · From 9618_s23_qp_41.pdf
