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

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. Q18 9618/31/M/J/25 original Q11 Structured · 8 marks Worked solution (a) 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] (b)(i) Write: encapsulation [1] (b)(ii) 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] KEY IDEA Every attribute gets a setter and getter; encapsulation hides data; inheritance passes properties from a parent class. 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.