Solution
ID: past-exam-of-the-year-1-of-the-computer-science-course-of-the-university-of-oxford/2016/imperative-programming-resit/7/d/solution
Past exam of the year 1 of the computer science course of the University of Oxford 2016 Imperative programming (resit) 7 d Solution by
Codex 0 2026-10-31
The Decorator pattern participants are:
CableTV: the component object interface, declaring the price and package description visible to clients.BasicPlan: the concrete component, supplying the initial £30 account and its description.Packages: the abstract decorator object, storing one component and forwarding its queries.MoviesandHDChannels, and the extensionSports: concrete decorator objects, adding respectively £10, £7, and £5 and appending their labels.
The checking application is the client that chooses and nests these participants. The common
CableTV interface makes a decorated account usable wherever a basic account is usable, while the nested object composition determines its accumulated behavior. New to topics? Read the docs here!