May/June 2026 Paper 43

2026 · 3 questions · 25 parts · 75 marks

0/75 marks
0Correct0Partial0Wrong25Unattempted
Filters0 active
Context for question 2
A prototype for a game is being developed using Object-Oriented Programming (OOP).
The game has a set of characters that have data stored about their characteristics, for example if the character can fly or not fly. A user has to select their requirements, for example a character that can fly, and the program will output the characters that meet the user's requirements.
The class Character stores the data about the characters. The attributes are public.
Character
CharacterName : Stringstores the character's name
Colour : Stringstores the colour of the character, for example "Green"
SuperStrength : Stringstores whether the character has super strength ("Yes") or not ("No")
Fly : Stringstores whether the character can fly ("Yes") or not ("No")
Invisible : Stringstores whether the character can become invisible ("Yes") or not ("No")
Constructor()initialises the attributes to its parameter values
GetCharacterName()returns CharacterName
GetColour()returns Colour
GetSuperStrength()returns SuperStrength
GetFly()returns Fly
GetInvisible()returns Invisible
2(a)(i)Classes ObjectsMedium4 marks
Write program code to declare the class Character and its constructor.
Use your programming language appropriate constructor.
If you are writing in Python, include attribute declarations using comments.

Answer

0 words
2(a)(ii)Classes ObjectsMedium3 marks
The get methods GetCharacterName(), GetColour(), GetSuperStrength(), GetFly() and GetInvisible() each return the appropriate attribute.
Write program code for GetCharacterName(), GetColour(), GetSuperStrength(), GetFly() and GetInvisible().

Answer

0 words
Context for 2(b)
The text file Characters.txt stores data about 15 characters. Each character is on a new line in the file. The data is stored in the order: Character name, colour, super strength, fly, invisible. Each value is separated by a comma.
For example, the first line in the file is:
text
Jet,Black,Yes,No,No
The name of the character is Jet. The colour of the character is Black. The character has super strength. The character cannot fly. The character cannot become invisible.
2(b)File Handling ExceptionsHard7 marks
The function ReadData():
  • opens the file Characters.txt and reads in the data
  • creates a new Character object for each character in the file
  • stores each Character object in a local array
  • returns the populated array.
The function uses exception handling when opening and reading from the file.
Write program code for ReadData().

Answer

0 words
2(c)ArraysMedium3 marks
The procedure OutputCharacters() takes an array of Character objects as a parameter. The procedure outputs the data for each character on a new line, in the format:
text
Name: <Character name>  Colour: <Colour>  Super strength: <Super strength>  Fly: <Fly>  Invisible: <Invisible>
For example:
text
Name: Jet  Colour: Black  Super strength: Yes  Fly: No  Invisible: No
Write program code for OutputCharacters().

Answer

0 words
2(d)(i)Subroutines Scope Modular ProgrammingEasy2 marks
The main program calls ReadData() and then OutputCharacters() with the returned array.
Write program code for the main program.

Answer

0 words
2(d)(ii)File Handling ExceptionsEasy1 mark
Test your program from 2(d)(i) using the supplied Characters.txt file.
Describe what your program outputs.

Answer

0 words
2(e)(i)Searching AlgorithmsHard8 marks
The main program needs to give the user two choices to limit the characters that they can choose from. For example, they could choose to only see characters that are green and that can fly.
The main program needs extending to:
  • prompt the user to enter two criteria and take both as input. For example, the colour green and that they have super strength.
  • create a new array with only the characters that meet both of the criteria.
You do not need to validate the inputs. You can assume that each criterion that the user inputs will be for a different characteristic of the character.
The main program should then:
  • output the number of characters that meet both criteria
  • use OutputCharacters() to output the characters that meet both criteria.
Write program code to extend the main program as described.

Answer

0 words
2(e)(ii)Searching AlgorithmsEasy1 mark
Run your extended program. Enter the options given when prompted: the first choice is characters with the colour black; the second choice is characters that can fly.
Describe exactly what your program outputs, in the order it is produced.

Answer

0 words