May/June 2026 Paper 41

2026 · 3 questions · 23 parts · 75 marks

0/75 marks
0Correct0Partial0Wrong23Unattempted
Filters0 active
Context for question 3
A prototype for a game is designed using Object-Oriented Programming (OOP).
The game will allow a character to move along a path (for example a road or sidewalk).
The prototype requires the classes setting up and the path creating, ready for the character to be implemented.
Each space in the path can contain an object. The path and objects are created as classes.
The class TheObject stores the data about the objects. The attributes are public.
TheObject
ObjectType : Stringstores the type of object, either "Money" or "Experience"
Amount : Integerstores the amount of the object, for example 200
Constructor()initialises the attributes to the parameter values
The class Path stores the data about the objects. The attributes are public.
Path
BoardArray[0:99] : TheObjectan array of 100 objects of type TheObject
NumberSpaces : Integerstores the number of spaces in the path
Constructor()initialises NumberSpaces to the parameter value. Initialises all 100 array objects to an empty object of type TheObject. An empty object has the values ObjectType = "" and
GetNumberSpaces()returns NumberSpaces
InitialiseData()takes an array of objects of type TheObject as a parameter and stores them in BoardArray
ReturnPath()returns a string created using data from each object in BoardArray
GetPathObject()takes a number as a parameter and returns the object at that index in BoardArray
3(a)(i)Classes ObjectsMedium4 marks
Write program code to declare the class TheObject and its constructor.
Use your programming language's appropriate constructor.
If you are writing in Python, include attribute declarations using comments.

Answer

0 words
3(a)(ii)Classes ObjectsMedium4 marks
Write program code to declare the class Path, its constructor and method GetNumberSpaces().
Use your programming language's appropriate constructor.
Do not declare the other methods.
If you are writing in Python, include attribute declarations using comments.

Answer

0 words
3(a)(iii)Classes ObjectsMedium3 marks
The method InitialiseData() takes an array of type TheObject as a parameter.
The method stores each element from the parameter array into the array BoardArray in the same order.
If there are more objects in the parameter array than in NumberSpaces, the method does not store the data and returns FALSE. Otherwise, it returns TRUE.
Write program code for InitialiseData().

Answer

0 words
3(a)(iv)Classes ObjectsEasy2 marks
The method ReturnPath() creates and returns a string containing the type and amount of each object that is not a null object in BoardArray, in the format:
text
<ObjectType>-<Amount>
For example, an array with two not-null objects produces the string:
output
Money-100 Experience-50
You can assume that there will always be an object that is not null in BoardArray.
Write program code for ReturnPath().

Answer

0 words
3(a)(v)Classes ObjectsEasy1 mark
The method GetPathObject() takes an integer index as a parameter and returns the object at the parameter index in BoardArray.
Write program code for GetPathObject().

Answer

0 words
3(b)(i)Classes ObjectsHard6 marks
Write program code for the main program to:
  • create a new array, ArrayOfObjects, of type TheObject with five spaces
  • store the following objects in each space in ArrayOfObjects, in the order given: money with amount 50; experience with amount 100; money with amount 200; money with amount 20; experience with amount 30
  • create a new object, Path1, of type Path with five spaces
  • call InitialiseData() for Path1 with ArrayOfObjects
  • call ReturnPath() for Path1 and output the return value

Answer

0 words
3(b)(ii)Classes ObjectsEasy1 mark
Test your program.
Describe exactly what your program outputs when ReturnPath() is called for Path1.

Answer

0 words