patterns/command/remoteundostatus/ceilingfan.d

50 lines
829 B
D
Raw Normal View History

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