Y13 Programming
Road Rage Quiz Scaffold
This page scaffolds OCR-style Question 1 (parts a-f) with coding checks and mark-scheme-aligned prompts.
- Main starter code for
PrizeandCharacter - Interactive checks for coding parts: b(i), b(ii), c(i), c(ii), d and e
- Writing frames and self-check criteria for theory parts: a, b(iii) and f
Python Runtime: Loading...
Main Python Code
Complete your class methods here, then run each question test below.
Main code output will appear here.
1(a) [3]
A game is being written that makes use of object-oriented programming. A prototype for one part of the game is being designed that includes a character, a road and a prize to collect.
The road will have 50 spaces that a character can move along. Each space on the road will store a null value or a prize object for the user to collect. Each space is numbered sequentially from the first space (position 0) to the last space (position 49) and will not change during the game. As the player travels down the road, the position the player is on the road will be output.
The road is designed to be a 1-dimensional array with the identifier road.
Explain why an array is a suitable data structure to represent the road.
Self-check feedback appears here.
Show mark-scheme points for 1(a)
- Fixed size matches 50 spaces
- Direct indexing makes position access easy
- Linear structure matches road progression
- Mutable entries allow null/prize updates
1(b)(i) [2]
i. The method getName() returns the data in the attribute name.
Write the method getName() in Python.
Test output will appear here.
Show model answer for 1(b)(i)
1(b)(ii) [3]
A global 1-dimensional array, allPrizes, stores 10 objects of type Prize.
The prize in index 3 has the name “Box”, the type is “money” and the value is 25.
Write program code to create a new object for this prize and store it in index 3 of allPrizes.
Test output will appear here.
Show model answer for 1(b)(ii)
1(b)(iii) [3]
The game starts with 10 prizes. Each prize is allocated to one space on the road.
An algorithm needs designing that will generate a random space on the road for each prize. Each road space can only store one prize.
Describe the decisions that will need to be made in this algorithm and how these will affect the program flow.
Self-check feedback appears here.
1(c)(i) [5]
The four get methods return the associated attribute.
The number of moves is passed to changePosition() as a parameter.
The method adds this value to the character’s position on the road.
The type and value of an object are passed to updateValues() as parameters:
- if the type is money, the value is added to the character’s money
- if the type is experience, the value is added to experience
- if the type is neither money nor experience, no changes are made
i. def __init__() is the constructor method.
The name of the character is passed into the constructor as a parameter.
The constructor initialises:
- experience to 0
- road position to 0
- money to 5
Write the constructor method for Character using either pseudocode or program code.
You do not need to declare the class, the attributes, or any other methods.
Test output will appear here.
Show model answer for 1(c)(i)
1(c)(ii) [5]
ii. The type and value of a prize are passed as parameters to the method updateValues. If the type is money the value is added to the character’s money. If the type is experience then the value is added to the experience. If the type is neither money or experience no changes are made.
For example, for the Character player1:
player1.updateValues("money",10) updates player1’s money by 10
player1.updateValues("experience",5) updates player1’s experience by 5
player1.updateValues("foo",9) has no effect on player1.
Write pseudocode or program code for the method updateValues().
Test output will appear here.
Show model answer for 1(c)(ii)
1(d) Complete pseudocode blanks [6]
This incomplete pseudocode algorithm:
• creates a new character with the name Jamal
• loops until the character reaches the end of the road
• generates a random number of spaces to move between 1 and 4 (including 1 and 4)
• moves the character and checks if the new space has a prize
• updates the character attributes if there is a prize
• outputs the character’s new attribute values.
Complete the pseudocode algorithm.
character1 = new (1) ("Jamal")
newPosition = 0
while newPosition < (2)
move = random(1, 4) //this will generate a random number between 1 and 4
character1.changePosition(move)
newPosition = character1.getRoadPosition()
if newPosition < 50 and road[(3)] != null then
prizeType = road[newPosition].getType()
valueAmount = road[newPosition].getValue()
character1.updateValues((4), valueAmount)
print("Congratulations you are in position", newPosition, "and found",
road[newPosition].getName())
print("Money =", character1.getMoney(), "and experience =",
character1.(5) ())
endif
(6)
print("You reached the end of the road")
| Gap | Choose word/term |
|---|---|
| (1) | |
| (2) | |
| (3) | |
| (4) | |
| (5) | |
| (6) |
1(d) feedback appears here.
Show expected answers for 1(d)
1(e) Correct four lines in displayRoad() [4]
(e) The procedure displayRoad() outputs the contents of each space in the road. The number of each space is output with either:
• the word “empty” if there is no prize
• the name of the prize if there is a prize.
01 procedure displayRoad()
02 for x = 0 to 60
03 print("Space", y)
04 if road[x] == null then
05 print("empty")
06 elseif
07 print(road[x].getValue())
08 endif
09 next x
10 endprocedure
The algorithm contains errors.
Give the line number of four different errors and write the corrected line for each error.
1(e) feedback appears here.
1(f) Global vs local variables discussion [9]
(f) A programmer is going to create a prototype for one small part of the game. Both road and allPrizes will be needed throughout the whole prototype. The programmer is considering making these global arrays as she thinks it will reduce the development time. Another programmer has suggested that doing this may create some problems when the rest of the game is created at a later stage.
Compare the use of global and local variables in this program.
You should include the following in your answer:
• the use of local and global variables
• alternative methods to using global variables
• the appropriateness of each to this program design
Self-check feedback appears here.
Show high-band checklist for 1(f)
- Define global vs local clearly in this game context
- Include alternatives: pass by value/reference, parameters/returns
- Apply to prototype: low data volume, faster development
- Apply to scaled game: debugging, coupling, maintenance risks
- Give balanced judgement with context-specific recommendation