patterns/facade/hometheater/amplifier.d

60 lines
1.1 KiB
D
Raw Permalink Normal View History

2022-12-05 07:38:19 +00:00
module amplifier;
import tuner, streamingplayer;
import std.stdio : writeln;
import std.conv : to;
class Amplifier
{
private string description;
private Tuner tuner;
private StreamingPlayer player;
this(string description)
{
this.description = description;
}
void on()
{
writeln(description ~ " on");
}
void off()
{
writeln(description ~ " off");
}
void setStereoSound()
{
writeln(description ~ " stereo mode on");
}
void setSurroundSound()
{
writeln(description ~ " surround sound on (5 speakers, 1 subwoofer)");
}
void setVolume(int level)
{
writeln(description ~ " setting volume to " ~ level.to!string);
}
void setTuner(Tuner tuner)
{
writeln(description ~ " setting tuner to " ~ tuner.to!string);
this.tuner = tuner;
}
void setStreamingPlayer(StreamingPlayer player)
{
writeln(description ~ " setting Streaming player to " ~ player.to!string);
this.player = player;
}
override string toString() const
{
return description;
}
}