Worked solution from the Data Representation Paper 3 Advanced Theory booklet, Part 1 of 3.
Say what it is for:
To create a new data type from existing data types [1]
To allow data types that the language does not provide to be built, which makes the language more flexible [1]
TYPE SchoolDay = (Monday, Tuesday, Wednesday, Thursday, Friday)
Write the whole definition above [1]
TYPE WeekEnd = (Saturday, Sunday)
Write the whole definition above [1]
A composite type groups several fields. Use the two enumerated types for the two days.
TYPE ClubMeet
DECLARE FirstName : STRING
DECLARE LastName : STRING
DECLARE Schoolday : SchoolDay
DECLARE Weekend : WeekEnd
ENDTYPETYPE ClubMeet and ENDTYPE written correctly [1]
FirstName and LastName declared with a correct data type (STRING) [1]
A field for the school day declared with the type SchoolDay from part (b)(i) [1]
A field for the weekend day declared with the type WeekEnd from part (b)(ii) [1]
▶ Topic lesson
A lesson on this topic · by ZAINEMATICS. 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.