Skip to main content
A-LevelComputer ScienceFurther programming9618/23 · Oct/Nov 2024 · Q816 Marks

A program is being developed to implement a game for up to six players. During the game, each player assembles a team of characters. At the start of the game there are 45 characters available. Each character has four attributes, as follows: Attribute | Examples | Comment ---|---|--- Player | 0, 1, 3 | The player the character is assigned to. Role | Builder, Teacher, Doctor | The job that the character will perform in the game. Name | Bill, Lee, Farah, Mo | The name of the character. Several characters may perform the same role, but they will each have a unique name. Skill level | 14, 23, 76 | An integer in the range 0 to 100, inclusive. The programmer has defined a record type to define each character. The record type definition is shown in pseudocode as follows: TYPE CharacterType DECLARE Player : INTEGER DECLARE Role : STRING DECLARE Name : STRING DECLARE SkillLevel : INTEGER ENDTYPE The Player field indicates the player to which the character is assigned (1 to 6). This field value is 0 if the character is not assigned to any player. The programmer has defined a global array to store the character data, as follows: DECLARE Character : ARRAY[1:45] OF CharacterType At the start of the game all record fields are initialised, and all Player fields are set to 0 The programmer has defined a program module as follows: Module | Description ---|--- Count() | • called with two parameters: o an integer representing a player o a string representing a character role | • searches the Character array for characters with the given role that are assigned to the given player | • counts the number of assigned characters and sums their total skill level | • outputs the result of the search if characters with the given role are found, for example: "Player 3 has 4 characters with the role of Teacher and the total skill level is 65" | • if no characters with the given role are found, outputs: "No characters with that role are assigned to this player"

  1. (a)Complete the pseudocode for module Count(). PROCEDURE Count(ThisPlayer : INTEGER, ThisRole : STRING) ENDFUNCTION[7]
  2. (b)The Character array data has been saved in the text file SaveFile.txt Each line of the file contains one element of the array (one record). New modules are defined: Module | Description ---|--- Extract() (already written) | • called with two parameters: o a string representing a complete line from the text file o an integer representing a field number (see structure below) | • returns a string representing the required field Restore() | • opens the text file SaveFile.txt | • reads lines from the file and assigns values to each record in the Character array using data from each line of the file As a reminder, the record structure is repeated here: TYPE CharacterType DECLARE Player : INTEGER //Field number 1 DECLARE Role : STRING //Field number 2 DECLARE Name : STRING //Field number 3 DECLARE SkillLevel : INTEGER //Field number 4 ENDTYPE Write pseudocode for module Restore(). You must use the module Extract().[7]
  3. (c)The game can last for several days and users often find that they have to close and rerun the game program many times in order to complete it. Describe the benefit of using the file SaveFile.txt as described in part (b).[2]

Mark scheme

Marking points from the official mark scheme (Oct/Nov 2024). The mark or mark type is shown in brackets.

  1. [1] MP1 Initialisation of local integers for Num and Total
  2. [1] MP2 Loop through 45 elements
  3. [1] MP3 Attempt to check Player and Role fields in a loop
  4. [1] MP4 Correctly compare Player field with parameter in a loop
  5. [1] MP5 Correctly compare Role field with parameter in a loop
  6. [1] MP6 ... if player and role found, increment Num and sum Skill Total in a loop
  7. [1] MP7 Test for any matches after the loop
  8. [1] MP8 Both possible OUTPUT statements correctly formed following an attempt at MP6 but outputting one only
  9. [1] MP1 Open the file in read mode and subsequently close
  10. [1] MP2 Loop through 45 elements
  11. [1] MP3 Read a line from the file in a loop
  12. [1] MP4 Attempt to use Extract() in a loop
  13. [1] MP5 Correct use of Extract() for all fields in a loop
  14. [1] MP6 Use of STR_TO_NUM() on Player and Skill in a loop
  15. [1] MP7 Completely correct extraction and assignment of all fields in a loop
  16. [1] MP1 The Character array / character data can be saved before the program is closed
  17. [1] MP2 Allowing the game to continue using the same data / from the point it was saved

Write your answer and get it marked

On Oracle Prep you can write or photograph your own answer and have it marked by AI against this mark scheme, with feedback on what you missed.

Sign up free →

About this question

Topic
Further programming, A-Level Computer Science (syllabus 9618). Structured question, 16 marks.
Source
A-Level Computer Science, Oct/Nov 2024 Paper 2 Variant 3, question 8.

Questions and mark schemes are from past examination papers and remain the copyright of the exam board. How Oracle Prep builds its content

Related Computer Science questions

© 2026 Oracle Prep