9618/32/O/N/22 question 10: worked solution (October/November 2022, 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. Q8 9618/32/O/N/22 original Q10 Structured · 6 marks Worked solution (a) Write one definition for each term: Encapsulation : putting the properties and methods inside a class , which hides the data from users [1] Getter : a method that returns the value of a property [1] Setter : a method that updates the value of a property [1] (b) Add the missing property (Telephone), then a setter and getter for each of the three properties. SubstituteTeacher ----------------- SubName : STRING Telephone : STRING InSchool : BOOLEAN ----------------- SetSubName(StaffName : STRING) SetTelephone(Tel : STRING) SetInSchool(Present : BOOLEAN) GetSubName() GetTelephone() GetInSchool() Properties correct: Telephone : STRING added [1] Setters correct: SetSubName and SetInSchool added [1] Getters correct: GetTelephone() and GetInSchool() added [1] KEY IDEA Private properties are read with getters and changed with setters, all kept together in the class (encapsulation). TOTAL 6 marks Official mark scheme VIDEO ▶ Whole paper Video solution of the whole paper · by qiphyedu. Tap the picture to open it on YouTube.