Past-paper question · 2018 October-November · Paper 43 · Q5(e)

Question 5(e) 2018 · October-November · Paper 43 · 6 marks

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

Official answer for Question 5

Part (e)

Question 1

mark per bullet point:

Question 6

✓
•
✓
function declaration (returning integer) and taking 2 cards as parameter
✓
•
✓
comparison of Number and Shape «
✓
•
✓
« if the same output ‘SNAP’ and return –1
✓
•
✓
Compare Number of each to find highest and return the highest number
✓
•
✓
return either number if the same
✓
•
✓
correct use of .GetNumber() and .GetShape()throughout
✓
9608/43
✓
Cambridge International AS/A Level – Mark Scheme
✓
October/November 2018
✓
PUBLISHED
✓
Question
✓
Answer
✓
Marks

Mark scheme 9608_w18_ms_43.pdf →

Show text version of question

Question 5

Part (e)

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 (e)

The game has a function, Compare() that takes two cards as parameters and compares

them.

If the cards are identical, the function outputs "SNAP" and returns −1. If they are not identical, and the card numbers are different, it returns the Number of the card with the higher value or the Number for the cards if they are the same.

Write program code for the Compare() function.

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

Program code

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

[6]

reasonable effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the publisher will be pleased to make amends at the earliest possible opportunity.

To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge International Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after the live examination series.

Cambridge International Examinations is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of University of Cambridge Local Examinations Syndicate (UCLES), which is itself a department of the University of Cambridge.

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_43.pdf

Keep practising this topic