Answer it
Composition, aggregation or inheritance at a school
5 marksYou mark it yourself against the marking points
A school timetable program has these classes: School, Room, Club, Student and Person.
- A
Schoolobject creates its ownRoomobjects. A room only exists as part of its school, and if the school is removed from the program, so are its rooms. - A
Clubholds a list of theStudentobjects that belong to it. Students exist before they join and stay after the club is closed. - A
Studentis a kind ofPerson, with an extra student number.
(a) Identify the relationship between each pair: School and Room, Club and Student, Student and Person. [3]
(b) A programmer suggests making Student a subclass of Club, so a student can use the club's list. Explain why this is a poor design. [2]
[5]