Worked solution from the Further Programming Paper 3 Advanced Theory booklet, Part 1 of 2.
Add attributes for patient and doctor, then setters and getters for every attribute.
Appointment DateSeen : DATE PatientID : INTEGER Doctor : STRING Treatments : STRING Medications : STRING ----- SetDateSeen(NewDate : DATE) SetPatientID(PatientNumber : INTEGER) SetDoctor(DoctorID : STRING) SetTreatments(NewTreatments : STRING) SetMedications(NewMedications : STRING) GetDateSeen() GetPatientID() GetDoctor() GetTreatments() GetMedications()
Two attributes: PatientID : INTEGER and Doctor : STRING [1]
SetTreatments(...) and SetMedications(...) written [1]
These two setters have appropriate parameters with STRING data types [1]
GetPatientID() and GetDoctor() written [1]
SetDateSeen with a DATE parameter, and GetDateSeen() written [1]
Write: encapsulation [1]
Write: inheritance is when a derived (child) class takes the attributes and methods of a parent (super / base) class. [1]
The inherited parts can be used, extended, changed or overridden in the subclass. [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.