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

50 lines
829 B
D
Raw Normal View History

2022-11-15 19:39:18 +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;
}
}