Cambridge A2 Level Computer Science 9618 · 20.1 Programming Paradigms

Q16 · 9618/31/O/N/24 Q9

Worked solution from the Further Programming Paper 3 Advanced Theory booklet, Part 1 of 2.

Q169618/31/O/N/24original Q9Structured · 6 marks
Question 9 from 9618/31/O/N/24

Worked solution

(a)

Write: PRIVATE attributes can only be used through the class's own methods (within the class), so other code cannot change them directly. [1]

(b)

Add two attributes, then a constructor, two setters and two getters:

Pet
PetID : STRING
PetType : STRING
OwnerTelephone : STRING
DateRegistered : DATE
PetName : STRING
OwnerName : STRING
-----
Constructor()
SetPetID(APetID : STRING)
SetDateRegistered(RegDate : DATE)
GetPetName()
GetOwnerTelephone()

Two attributes with sensible names and correct data types (PetName : STRING, OwnerName : STRING) [1]

A constructor to create the object [1]

Two setters with correct names and parameters (SetPetID, SetDateRegistered with a DATE parameter) [1]

Two getters with sensible names (GetPetName, GetOwnerTelephone) [1]

The pet name getter uses the same name as the attribute (PetName) [1]

KEY IDEAA class diagram lists attributes with data types above and methods (constructor, setters, getters) below.
TOTAL 6 marks

Official mark scheme

Mark scheme for 9618/31/O/N/24 question 9
VIDEO
▶ Topic lesson

A lesson on this topic · by Craig'n'Dave. Tap the picture to open it on YouTube.

Solutions follow the official Cambridge mark schemes; marks are shown in grey. Videos are from other YouTube channels. Paper codes read component / series / year: M/J = May/June, O/N = October/November. Past-paper questions © UCLES, reproduced for classroom practice.