patterns/command/remoteundostatusmacro/hottub.d

59 lines
975 B
D

module command.remoteundostatusmacro.hottub;
import std.stdio : writeln;
import std.conv : to;
class Hottub
{
private bool isOn;
private int temperature;
void on()
{
isOn = true;
}
void off()
{
isOn = false;
}
void circulate()
{
if (isOn)
{
writeln("Hottub is bubbling!");
}
}
void jetsOn()
{
if (isOn)
{
writeln("Hottub jets are on");
}
}
void jetsOff()
{
if (isOn)
{
writeln("Hottub jets are off");
}
}
void setTemperature(int temperature)
{
if (temperature > this.temperature)
{
writeln("Hottub is heating to a steaming " ~ temperature.to!string ~ " degrees");
}
else
{
writeln("Hottub is cooling to " ~ temperature.to!string ~ " degrees");
}
this.temperature = temperature;
}
}