public void Undo() { if (prevSpeed == CeilingFan.High) { ceilingFan.high(); } if (prevSpeed == CeilingFan.Medium) { ceilingFan.medium(); } if (prevSpeed == CeilingFan.Low) { ceilingFan.low(); } if (prevSpeed == CeilingFan.Off) { ceilingFan.off(); } }
public void Execute() { //执行前先记录速度,方便撤销 prevSpeed = ceilingFan.GetSpeed(); ceilingFan.off(); }