9618/32/M/J/25 question 12: worked solution (May/June 2025, paper 32)

Show as plain text

Cambridge A2 Level Computer Science 9618 · 20.1 Programming Paradigms Worked solution from the Further Programming Paper 3 Advanced Theory booklet, Part 1 of 2. Q19 9618/32/M/J/25 original Q12 Structured · 8 marks 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 IDEA A class diagram lists attributes with data types, then setter methods with parameters and getter methods without. TOTAL 8 marks Official mark scheme VIDEO ▶ Topic lesson A lesson on this topic · by Craig'n'Dave. Tap the picture to open it on YouTube.