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

49 lines
769 B
D

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;
}
}