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

Question 2(c) 2023 · May-June · Paper 41 · 3 marks

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

Official answer for Question 2

Part (c)

Question 1

mark each to max 3

Question 3

✓
Suitable method/procedure heading (and end where appropriate) and outputting horizontal position and current speed
✓
in an appropriate message
✓
Checking if object is a Vehicle or Helicopter // overriding methods in each class for output // one method in each class
✓
// try except …
✓
…outputting vertical position only if helicopter with appropriate message
✓
Example program code:
✓
VB.NET
✓
Sub OutputCurrentPosition(ObjectToOutput)
✓
Console.WriteLine("Current position = " & ObjectToOutput.GetHorizontalPosition())
✓
Console.WriteLine("Current speed = " & ObjectToOutput.GetCurrentSpeed())
✓
If TypeOf ObjectToOutput Is Helicopter Then
✓
Console.WriteLine("Current vertical position = " &
✓
ObjectToOutput.GetVerticalPosition())
✓
End If
✓
End Sub
✓
Java
✓
public void OutputCurrentPosition(){
✓
System.out.println("Current position = " + HorizontalPosition);
✓
System.out.println("Current speed = " + CurrentSpeed);
✓
}
✓
public void OutputCurrentPosition(){
✓
System.out.println("Current position = " +super.GetHorizontalPosition());
✓
System.out.println("Current speed = " + super.GetCurrentSpeed());
✓
System.out.println("Current vertical position = " + VerticalPosition);
✓
}
✓
Python
✓
def OutputCurrentPosition(self):
✓
print("Current position = ", self.__HorizontalPosition)
✓
print("Current speed = ", self.__CurrentSpeed)
✓
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 (c)

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

Part (c)

A procedure needs to output the horizontal position and speed of a vehicle. If the vehicle is a

helicopter, it also outputs the vertical position.

All outputs must include appropriate messages.

Write program code for this procedure.

Save your program.

Copy and paste the program code into part 2(c) in the evidence document.

[3]
Topic relevance

Why this question appears here

71% 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