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/ceilingfanmediumcommand.d

42 lines
893 B
D

module command.remoteundostatus.ceilingfanmediumcommand;
import command.remoteundostatus.command;
import command.remoteundostatus.ceilingfan;
class CeilingFanMediumCommand : Command
{
CeilingFan ceilingFan;
int prevSpeed;
this(CeilingFan ceilingFan)
{
this.ceilingFan = ceilingFan;
}
void execute()
{
prevSpeed = ceilingFan.getSpeed();
ceilingFan.medium();
}
void undo()
{
switch (prevSpeed)
{
case CeilingFan.HIGH:
ceilingFan.high();
break;
case CeilingFan.MEDIUM:
ceilingFan.medium();
break;
case CeilingFan.LOW:
ceilingFan.low();
break;
case CeilingFan.OFF:
ceilingFan.off();
break;
default: break;
}
}
}