Past-paper question · 2023 May-June · Paper 41 · Q2(b)(ii)

Question 2(b)(ii) 2023 · May-June · Paper 41 · 4 marks

Original past-paper question for 2(B)(II)
Original past-paper question for 2(B)(II)
Original past-paper question for 2(B)(II)
Original past-paper question for 2(B)(II)
Reveal official mark-scheme answer Official mark-scheme answer for 2(B)(II)

Official answer for Question 2

Part (b)

(ii)

Question 1

mark each to max 4

Question 4

✓
Method header (overriding where required) with no parameter
✓
Adding vertical change to vertical position …
✓
…limiting to maximum height
✓
Repeating/calling/using the code from original for horizontal increase (in every case)
✓
Example program code:
✓
VB.NET
✓
Overrides Sub IncreaseSpeed()
✓
VerticalPosition = VerticalPosition + VerticalChange
✓
If VerticalPosition > MaxHeight Then
✓
VerticalPosition = MaxHeight
✓
End If
✓
Me.SetCurrentSpeed(GetCurrentSpeed() + GetIncreaseAmount())
✓
If Me.GetCurrentSpeed() > Me.GetMaxSpeed() Then
✓
Me.SetCurrentSpeed(Me.GetMaxSpeed())
✓
End If
✓
Me.SetHorizontalPosition(Me.GetHorizontalPosition() + Me.GetCurrentSpeed())
✓
End Sub
✓
Java
✓
public void IncreaseSpeed(){
✓
VerticalPosition = VerticalPosition + VerticalChange;
✓
if(VerticalPosition > MaxHeight){
✓
VerticalPosition = MaxHeight;
✓
}
✓
super.SetCurrentSpeed(super.GetCurrentSpeed() + super.GetIncreaseAmount());
✓
if(super.GetCurrentSpeed() > super.GetMaxSpeed()){
✓
super.SetCurrentSpeed(super.GetMaxSpeed());
✓
}
✓
super.SetHorizontalPosition(super.GetHorizontalPosition() + super.GetCurrentSpeed());
✓
}
✓
9618/41
✓
Cambridge International AS & A Level – Mark Scheme
✓
May/June 2023
✓
PUBLISHED
✓
Question
✓
Answer
✓
Marks

Mark scheme 9618_s23_ms_41.pdf →

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.

[4]

Question 7

Topic relevance

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

Keep practising this topic