Past-paper question · 2018 October-November · Paper 41 · Q5(b)

Question 5(b) 2018 · October-November · Paper 41 · 5 marks

Original past-paper question for 5(B)
Original past-paper question for 5(B)
Reveal official mark-scheme answer Official mark-scheme answer for 5(B)Official mark-scheme answer for 5(B)

Official answer for Question 5

Part (b)

Question 1

mark per bullet point:

Question 5

✓
•
✓
Constructor method header taking 2 parameters (with correct data types if given)
✓
•
✓
Checking if Number > = 0 and < = 9
✓
•
✓
Checking theShape is ‘square’ or ‘triangle’ or ‘circle’
✓
•
✓
« if both valid assigning Number and Shape the parameters
✓
•
✓
« if either invalid report error (output/returning value/catching error)
✓
9608/41
✓
Cambridge International AS/A Level – Mark Scheme
✓
October/November 2018
✓
PUBLISHED
✓
Question
✓
Answer
✓
Marks

Mark scheme 9608_w18_ms_41.pdf →

Show text version of question

Question 5

Part (b)

Question 5

A game uses a set of cards. Each card has a number (between 0 and 9 inclusive) and a shape

("square", "triangle" or "circle").

The game is written using object-oriented programming.

The class, Cards, has the private properties:

  • Number
  • Shape

and the methods:

  • Constructor()
  • GetNumber()
  • GetShape()

The purpose of each method in the class Cards is given in the following table.

Method Purpose Constructor() Takes a number and a shape as parameters Checks that the number and the shape are valid and:

  • either assigns the parameters to Number and Shape
  • or reports an error.

GetNumber() A public method that returns the number for that card. GetShape() A public method that returns the shape for that card.

Part (b)

Write program code for the Constructor() method.

Programming language ............................................................................................................

Program code

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

..............................................................................................................................................

[5]
Topic relevance

Why this question appears here

98% assigned-topic match · Further programming › Programming paradigms

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 9608_w18_qp_41.pdf

Keep practising this topic