Cambridge A2 Level Computer Science 9618 · 20.1 Programming Paradigms

Q18 · 9618/31/M/J/25 Q11

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

Q189618/31/M/J/25original Q11Structured · 8 marks
Question 11 from 9618/31/M/J/25

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 IDEAEvery attribute gets a setter and getter; encapsulation hides data; inheritance passes properties from a parent class.
TOTAL 8 marks

Official mark scheme

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