Past-paper question · 2025 October-November · Paper 43 · Q9(d)

Question 9(d) 2025 · October-November · Paper 43 · 25 marks

Question 9

Part (d)

Question 9

The class Board stores the data about the board and where the board objects are placed.

Board TheBoard : ARRAY[0:9, 0:9] of BoardObject stores the board contents as a 2D array of 10 x 10 elements of type BoardObject Constructor() initialises each of TheBoard elements to an empty BoardObject with Code = "-" and Value = 0

GetObject() takes a row and column number as parameters and returns the BoardObject at the row, column position

SetObject() takes a BoardObject, row number and column number as parameters. Stores the BoardObject in TheBoard at the given row, column position

DisplayBoard() outputs the code of each BoardObject stored in TheBoard, one row at a time

Question 5

(i)

Write program code to declare the class Board and its constructor.

Do not declare the other methods.

Use your programming language appropriate constructor.

If you are writing in Python, include attribute declarations using comments.

Save your program.

Copy and paste the program code into part 1(b)(i) in the evidence document.

[4]

(ii)

The method GetObject() takes a row number and column number as parameters.

The method returns the BoardObject stored at the parameter position.

Write program code for GetObject()

Save your program.

Copy and paste the program code into part 1(b)(ii) in the evidence document.

[2]

(iii)

The method SetObject() takes three parameters: a BoardObject, row number and

column number.

The method stores the BoardObject parameter in the row, column position in TheBoard

Write program code for SetObject()

Save your program.

Copy and paste the program code into part 1(b)(iii) in the evidence document.

[2]

Question 6

(iv)

The method DisplayBoard() outputs the Code of each BoardObject stored in

TheBoard using GetCode()

Each row in TheBoard is output on one line with a space between each Code

For example, the following board contains these four board objects:

  • one object has code "A" in row 0 column 7
  • one object has code "B" in row 0 column 9
  • one object has code "C" in row 1 column 1
  • one object has code "E" in row 6 column 5

The other board objects are empty. The output for this board will be:

  • - - - - - - A - B
  • C - - - - - - - -
  • - - - - - - - - -
  • - - - - - - - - -
  • - - - - - - - - -
  • - - - - - - - - -
  • - - - - E - - - -
  • - - - - - - - - -
  • - - - - - - - - -
  • - - - - - - - - -

Write program code for DisplayBoard()

Save your program.

Copy and paste the program code into part 1(b)(iv) in the evidence document.

[3]

Question 7

Part (c)

(i)

The table gives the row and column position on the board to store each of the five objects

created in part 1(a)(iii).

Object column row position identifier position Object1 0 0 Object2 9 9 Object3 4 5 Object4 2 2 Object5 8 7

Write program code to amend the main program to:

  • declare a new instance of Board()
  • store each BoardObject in the position given in the table
  • call DisplayBoard() for the new board object.

Save your program.

Copy and paste the program code into part 1(c)(i) in the evidence document.

[3]

(ii)

Test your program.

Take a screenshot of the output(s).

Save your program.

Copy and paste the screenshot(s) into part 1(c)(ii) in the evidence document.

[1]

Question 8

Part (d)

(i)

Amend the main program to:

  • repeatedly take a row position as input until it is between 0 and 9 inclusive
  • repeatedly take a column position as input until it is between 0 and 9 inclusive
  • use the appropriate method(s) to identify if there is an object in the array position
  • input

  • output "Miss" if there is an empty BoardObject in that position
  • output the Code and Value if there is a non-empty BoardObject in that position.

All outputs must include appropriate messages.

Save your program.

Copy and paste the program code into part 1(d)(i) in the evidence document.

[4]

(ii)

Test your program by entering this test data in the order given:

Row position first input: 10

Row position second input: 4

Column position first input: –1

Column position second input: 5

Take a screenshot of the output(s).

Save your program.

Copy and paste the screenshot(s) into part 1(d)(ii) in the evidence document.

[1]

Question 9

2 A program reads string data from a text file into a linear queue and then compresses the data.

The queue is created using the global 1D array Queue. The queue can store up to 100 elements. Each element is initialised to the empty string ""

The queue has two pointers that are global to the program:

  • QueueHead that points to the index of the first element in the queue, initialised to –1
  • QueueTail that points to the index of the last element in the queue, initialised to –1

The global variable NumberItems stores the number of elements stored in the queue, initialised to 0

Part (d)

The text file BinaryData.txt stores individual binary digits, '1' and '0'. Each digit is on

a new line. For example, the first line in the text file stores '1', the second line stores '1'

The procedure ReadData() reads in each line from the text file BinaryData.txt and inserts it into the queue using the appropriate method.

The procedure needs to work for a text file with any number of lines up to a maximum of 100.

Write program code for ReadData()

Save your program.

Copy and paste the program code into part 2(d) in the evidence document.

[5]
Reveal official mark-scheme answer

The answer for this question is in the official mark scheme: open the mark scheme.

Mark scheme 9618_w25_ms_43.pdf →

Topic relevance

Why this question appears here

72% assigned-topic match · Programming › Programming basics

Topic-match percentages estimate how closely each question fits the selected syllabus topic. They are a guide for choosing stricter or broader practice.

Permanent source page: Educate A Change · From 9618_w25_qp_43.pdf

Keep practising this topic