Exercise: Facade
This exercise puts the Facade pattern into code.
Scenario
A home theater system has four independent subsystems: Lights, Screen, Projector, and
SoundSystem. Each subsystem exposes simple methods that return a string describing the action
it just performed. A HomeTheaterFacade sits in front of them and exposes two high-level
operations — watch to start a movie and end to shut everything down — so callers never
need to know the subsystem order or method names.
Commands
| Command | Behavior | Output |
|---|---|---|
["watch"] | Start a movie: dim lights, lower screen, turn on projector, turn on sound | four lines, one per subsystem action, in order |
["end"] | Shut down: turn off projector, turn off sound, raise screen, turn on lights | four lines, one per subsystem action, in order |
2 watch end
Lights: dim to 10% Screen: down Projector: on Sound: on at volume 8 Projector: off Sound: off Screen: up Lights: on
Your task
Create the HomeTheaterFacade class so the commands produce the output above. The starter
keeps all four subsystem classes (Lights, Screen, Projector, SoundSystem) and the
run_theater dispatcher, and marks where to add HomeTheaterFacade with a TODO comment
listing its constructor signature, the watch method (which calls the subsystems in the
documented order and returns the lines), and the end method (which does the same for
shutdown).