Worked solution from the Further Programming Paper 3 Advanced Theory booklet, Part 1 of 2.
Write: PRIVATE attributes can only be used through the class's own methods (within the class), so other code cannot change them directly. [1]
Add two attributes, then a constructor, two setters and two getters:
Pet PetID : STRING PetType : STRING OwnerTelephone : STRING DateRegistered : DATE PetName : STRING OwnerName : STRING ----- Constructor() SetPetID(APetID : STRING) SetDateRegistered(RegDate : DATE) GetPetName() GetOwnerTelephone()
Two attributes with sensible names and correct data types (PetName : STRING, OwnerName : STRING) [1]
A constructor to create the object [1]
Two setters with correct names and parameters (SetPetID, SetDateRegistered with a DATE parameter) [1]
Two getters with sensible names (GetPetName, GetOwnerTelephone) [1]
The pet name getter uses the same name as the attribute (PetName) [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.