Worked solution from the Further Programming Paper 3 Advanced Theory booklet, Part 1 of 2.
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]
Write: instance (instantiation is also accepted) [1]
Write that polymorphism is when methods with the same name are redefined or behave differently [1]
... in derived (inherited) classes, also called subclasses [1]
▶ 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.