9618/31/O/N/24 question 9: worked solution (October/November 2024, paper 31)
Show as plain textHide 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. Q16 9618/31/O/N/24 original Q9 Structured · 6 marks Worked solution (a) Write: PRIVATE attributes can only be used through the class's own methods (within the class), so other code cannot change them directly. [1] (b) 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] KEY IDEA A class diagram lists attributes with data types above and methods (constructor, setters, getters) below. TOTAL 6 marks Official mark scheme VIDEO ▶ Topic lesson A lesson on this topic · by Craig'n'Dave. Tap the picture to open it on YouTube.