patterns/command/remote/ceilingfan.d

49 lines
769 B
D
Raw Normal View History

2022-12-05 07:38:19 +00:00
module command.remote.ceilingfan;
import std.stdio : writeln;
class CeilingFan
{
private string location;
private int level;
static int HIGH = 2;
static int MEDIUM = 1;
static int LOW = 0;
this(string location)
{
this.location = location;
}
void high()
{
level = HIGH;
writeln(location ~ " ceiling fan is on high");
}
void medium()
{
level = MEDIUM;
writeln(location ~ " ceiling fan is on medium");
}
void low()
{
level = LOW;
writeln(location ~ " ceiling fan is on low");
}
void off()
{
level = 0;
writeln(location ~ " ceiling fan is off");
}
int getSpeed()
{
return level;
}
}