Cambridge A2 Level Computer Science 9618 · 20.1 Programming Paradigms

Q19 · 9618/32/M/J/25 Q12

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

Q199618/32/M/J/25original Q12Structured · 8 marks
Question 12 from 9618/32/M/J/25

Worked solution

(a)

Add two attributes, then the missing methods. Setters take a parameter. Getters take none. Write the completed class diagram:

Patient
PatientID : STRING
Name : STRING
DateOfBirth : DATE
Priority : INTEGER
DoctorID : STRING

SetPatientID(PatientNumber : STRING)
SetName(FullName : STRING)
SetDateOfBirth(DOB : DATE)
SetPriority(Urgency : INTEGER)
SetDoctorID(DocID : STRING)
GetPatientID()
GetName()
GetDateOfBirth()
GetPriority()
GetDoctorID()

Two correct attributes: DateOfBirth : DATE and a sensibly named priority with data type INTEGER [1]

SetPatientID(...) and SetDoctorID(...) methods written [1]

Both of those setters have a sensible parameter with data type STRING [1]

GetPatientID() and GetDateOfBirth() written [1]

Priority setter and getter written with names matching the attribute, the setter having an INTEGER parameter, for example SetPriority(Urgency : INTEGER) and GetPriority() [1]

(b)(i)

Write: instance (instantiation is also accepted) [1]

(b)(ii)

Write that polymorphism is when methods with the same name are redefined or behave differently [1]

... in derived (inherited) classes, also called subclasses [1]

KEY IDEAA class diagram lists attributes with data types, then setter methods with parameters and getter methods without.
TOTAL 8 marks

Official mark scheme

Mark scheme for 9618/32/M/J/25 question 12
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.