CSc9618(A2) - Mock 4 - Paper 4
CSc9618(A2) - Mock 4 - Paper 4
A2 Level
Exam Topic: Full Syllabus
Paper 4 Duration: 1.5 hours Total Marks: 75
Make sure that your name, centre number and candidate number will appear on every page of this
document. This document must contain your answers to each question.
1 The text file HighScore.txt stores the players who have scored the top ten scores in a game,
in descending order of score. The file stores the 3-character name of the player, and their integer
score, in the order: player, score.
The program:
(a) The program stores the players and their scores in an array of 11 elements (10 elements to
be read from the file, 1 element to be inserted by the user).
Write a program to declare one or more arrays, as global data structures, to store the player
names and their scores.
Copy and paste the program code into part 1(a) in the evidence document.
[2]
(b) The procedure ReadHighScores() opens the file HighScore.txt and reads the data into
the data structure(s) declared in part 1(a).
Copy and paste the program code into part 1(b) in the evidence document.
[6]
(c) The procedure OutputHighScores() outputs all the values in the data structure(s) in the
format:
PlayerName Score
Copy and paste the program code into part 1(c) in the evidence document.
[3]
(d) The main program should first call ReadHighScores() and then OutputHighScores().
Copy and paste the program code into part 1(d)(i) in the evidence document.
[2]
Copy and paste the screenshot into part 1(d)(ii) in the evidence document.
[1]
(e) The main program needs to ask the user to input a new player name and a score. If this score
is in the top ten then it will create a new top ten list that includes this score.
(i) Amend the main program to ask the user to input a 3-character player name and an
integer score that must be between 1 and 100 000 inclusive.
Copy and paste the program code into part 1(e)(i) in the evidence document.
[3]
Copy and paste the program code into part 1(e)(ii) in the evidence document.
[5]
(iii) Amend the main program to call the procedure from part 1(e)(ii).
Output the contents of the array before inserting the new player name and score, and
output the contents of the array after inserting the new player name and score.
Copy and paste the program code into part 1(e)(iii) in the evidence document.
[2]
(iv) Test your program by entering the player name "JKL" and the score "9999".
Copy and paste the screenshot into part 1(e)(iv) in the evidence document.
[1]
(f) The procedure WriteTopTen() stores the new top ten player names and scores in a text
file called NewHighScore.txt
Copy and paste the program code into part 1(f) in the evidence document.
[4]
2 A computer game is being developed using object-oriented programming.
One element of the game is a balloon. This is designed as the class Balloon.
Balloon
Health : INTEGER The health of the balloon
(a) The constructor takes the name of the defence item and the balloon’s colour as parameters
and sets these to the attributes. The health is initialised to 100.
Write program code to declare the class Balloon and its constructor. Do not write any other
methods.
All attributes should be private. If you are writing in Python include attribute declarations using
comments.
Copy and paste the program code into part 2(a) in the evidence document.
[5]
(b) The get method GetDefenceItem() returns the defence item of the object.
Copy and paste the program code into part 2(b) in the evidence document.
[2]
(c) The object’s method ChangeHealth() takes an integer number as a parameter and adds
this to the health attribute of the object.
Copy and paste the program code into part 2(c) in the evidence document.
[2]
(d) The object’s method CheckHealth() returns TRUE if the health of the object is 0 or less (no
health remaining) and returns FALSE otherwise (health remaining).
Copy and paste the program code into part 2(d) in the evidence document.
[2]
Copy and paste the program code into part 2(e) in the evidence document.
[3]
Copy and paste the program code into part 2(f) in the evidence document.
[8]
(g) (i) Amend the main program to call the function Defend().
Copy and paste the program code into part 2(g)(i) in the evidence document.
[2]
Copy and paste the screenshot into part 2(g)(ii) in the evidence document.
[1]
3 A program uses a circular queue to store strings. The queue is created as a 1D array, QueueArray,
with 10 string items.
(a) Declare the array, head pointer, tail pointer and number of items.
Copy and paste the program code into part 3(a) in the evidence document.
[2]
(b) The function Enqueue is written in pseudocode. The function adds DataToAdd to the queue.
It returns FALSE if the queue is full and returns TRUE if the item is added.
RETURN ……………………………………
ENDIF
QueueArray[……………………………………] ← DataToAdd
IF TailPointer >= 9 THEN
TailPointer ← ……………………………………
ELSE
TailPointer ← TailPointer + 1
ENDIF
ENDFUNCTION
Copy and paste the program code into part 3(b) in the evidence document.
[7]
(c) The function Dequeue() returns "FALSE" if the queue is empty, or it returns the next data
item in the queue.
Copy and paste the program code into part 3(c) in the evidence document.
[6]
(d) (i) Amend the main program to:
Copy and paste the program code into part 3(d)(i) in the evidence document.
[5]
"A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K"
Copy and paste the screenshot into part 3(d)(ii) in the evidence document.
[1]