public function undo()
 {
     switch ($this->prevSpeed) {
         case CeilingFan::HIGH:
             $this->ceilingFan->high();
             break;
         case CeilingFan::MEDIUM:
             $this->ceilingFan->medium();
             break;
         case CeilingFan::LOW:
             $this->ceilingFan->low();
             break;
         default:
             $this->ceilingFan->off();
             break;
     }
 }
 public function undo()
 {
     if ($this->prevSpeed == CeilingFan::HIGH) {
         $this->ceilingFan->high();
     } else {
         if ($this->prevSpeed == CeilingFan::MEDIUM) {
             $this->ceilingFan->medium();
         } else {
             if ($this->prevSpeed == CeilingFan::LOW) {
                 $this->ceilingFan->low();
             } else {
                 if ($this->prevSpeed == CeilingFan::OFF) {
                     $this->ceilingFan->off();
                 }
             }
         }
     }
 }
 public function execute()
 {
     $this->ceilingFan->high();
 }
require_once "TVOffCommand.php";
require_once "TVOnCommand.php";
require_once "CloseDoorCommand.php";
require_once "OpenDoorCommand.php";
require_once "LightOffCommand.php";
require_once "CeilingFanOffCommand.php";
require_once "CeilingFanLowCommand.php";
require_once "CeilingFanMediumCommand.php";
require_once "CeilingFanHighCommand.php";
require_once "RemoteControl.php";
//--------------------------------------------------------
//Создаём пульт управления
$remoteControl = new RemoteControl();
echo "<b>Start remote control.</b><hr>";
//Создаём команды для вентилятора
$fan = new CeilingFan("GuestRoom");
$fanLow = new CeilingFanLowCommand($fan);
$fanMedium = new CeilingFanMediumCommand($fan);
$fanHigh = new CeilingFanHighCommand($fan);
$fanOff = new CeilingFanOffCommand($fan);
//Назначаем команды
$remoteControl->setCommand(0, $fanLow, $fanOff);
$remoteControl->setCommand(1, $fanMedium, $fanOff);
$remoteControl->setCommand(2, $fanHigh, $fanOff);
echo "<b>Remote control initialized.</b><hr>";
//----- тестируем пульт
echo "<b>Test remote control.</b><hr>";
echo "<i>All device online:<br></i>";
$remoteControl->onButtonWasPressed(0);
$remoteControl->onButtonWasPressed(1);
$remoteControl->undoButtonWasPressed();
 public function execute()
 {
     $this->ceilingFan->off();
 }