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.
| ObjectType : String | stores the type of object, either "Money" or "Experience" |
|---|---|
| Amount : Integer | stores 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.
| BoardArray[0:99] : TheObject | an array of 100 objects of type TheObject |
|---|---|
| NumberSpaces : Integer | stores 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 |