9618/32/M/J/22 question 1: worked solution (May/June 2022, paper 32)
Show as plain textHide plain text
Cambridge A2 Level Computer Science 9618 · 13.1 User-defined data types Worked solution from the Data Representation Paper 3 Advanced Theory booklet, Part 1 of 3. Q4 9618/32/M/J/22 original Q1 Structured · 9 marks Worked solution (a) BuildingRegister.BuildingID ← 1067 BuildingRegister.BuildingGroup ← "house" BuildingID assigned 1067 [1] BuildingGroup assigned the text house in quotes [1] (b)(i) TYPE BuildingType = (house, bungalow, apartment, farm) TYPE BuildingType = [1] (house, bungalow, apartment, farm) [1] (b)(ii) DECLARE BuildingGroup : BuildingType Field declared with the type BuildingType [1] (b)(iii) House is now an enumerated value, so no quotes. BuildingRegister.BuildingGroup ← house Assignment with house and no quotes [1] (c)(i) PRIVATE OwnerName : STRING PRIVATE OwnerName : STRING [1] (c)(ii) Private properties can only be accessed by the class's own methods [1] This is encapsulation : the data is hidden, so other code cannot change it by mistake [1] KEY IDEA Enumerated values are written without quotes, and PRIVATE properties are hidden to give encapsulation. TOTAL 9 marks Official mark scheme VIDEO ▶ Whole paper Video solution of the whole paper · by qiphyedu. Tap the picture to open it on YouTube.