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/command/remoteundo/ceilingfan.d

49 lines
773 B
D
Raw Normal View History

2022-11-15 19:11:46 +00:00
module command.remoteundo.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;
}
}