This repository has been archived on 2022-11-20. You can view files and clone it, but cannot push or open issues or pull requests.
patterns/facade/hometheater/hometheaterfacade.d

83 lines
1.8 KiB
D
Raw Normal View History

2022-11-16 13:43:46 +00:00
module hometheaterfacade;
import std.stdio : writeln;
import amplifier, tuner, streamingplayer, cdplayer, projector, theaterlights, screen, popcornpopper;
class HomeTheaterFacade
{
private Amplifier amp;
private Tuner tuner;
private StreamingPlayer player;
private CdPlayer cd;
private Projector projector;
private TheaterLights lights;
private Screen screen;
private PopcornPopper popper;
this(Amplifier amp,
Tuner tuner,
StreamingPlayer player,
CdPlayer cd,
Projector projector,
TheaterLights lights,
Screen screen,
PopcornPopper popper)
{
this.amp = amp;
this.tuner = tuner;
this.player = player;
this.cd = cd;
this.projector = projector;
this.lights = lights;
this.screen = screen;
this.popper = popper;
}
void watchMovie(string movie)
{
writeln("Get ready to watch a movie...");
popper.on();
popper.pop();
lights.dim(10);
screen.down();
projector.on();
projector.wideScreenMode();
amp.on();
amp.setStreamingPlayer(player);
amp.setSurroundSound();
amp.setVolume(5);
player.on();
player.play(movie);
}
void endMovie()
{
writeln("Shutting movie theater down...");
popper.off();
lights.on();
screen.up();
projector.off();
amp.off();
player.stop();
player.off();
}
void listenToRadio(double frequency)
{
writeln("Tuning in the airwaves...");
tuner.on();
tuner.setFrequency(frequency);
amp.on();
amp.setVolume(5);
amp.setTuner(tuner);
}
void endRadio()
{
writeln("Shutting down the tuner...");
tuner.off();
amp.off();
}
}