<?php include_once __DIR__ . "/remoteControl.php"; include_once __DIR__ . "/devices/light.php"; include_once __DIR__ . "/commands/lightOnCommand.php"; include_once __DIR__ . "/commands/lightOffCommand.php"; $device = new RemoteControl(); $light = new Light("Bathroom"); $lightOnCommand = new lightOnCommand($light); $lightOffCommand = new lightOffCommand($light); $device->setCommand(1, $lightOnCommand, $lightOffCommand); $light = new Light("Kitchen"); $lightOnCommand = new lightOnCommand($light); $lightOffCommand = new lightOffCommand($light); $device->setCommand(2, $lightOnCommand, $lightOffCommand); $device->onButtonWasPushed(1); $device->onButtonWasPushed(2); $device->undoButtonWasPushed(); $device->undoButtonWasPushed();
$remote = new SimpleRemoteControl(); $light = new Machine\Light("Corridor Light"); $lightOn = new Command\LightOnCommand($light); $remote->setCommand($lightOn); $remote->buttonWasPressed(); //Remote Control $re = new RemoteControl(); $livingRoom = new Machine\Light('Living Room'); $kitchenLight = new Machine\Light('Kitchen'); $ceilingFan = new Machine\CeilingFan('Living Room'); $garageDoor = new Machine\GarageDoor('Main'); $stereo = new Machine\Stereo('My Room'); $re->setCommand(0, new Command\LightOnCommand($livingRoom), new Command\LightOffCommand($livingRoom)); $re->setCommand(1, new Command\LightOnCommand($kitchenLight), new Command\LightOffCommand($kitchenLight)); $re->setCommand(2, new Command\CeilingFanHighCommand($ceilingFan), new Command\CeilingFanOffCommand($ceilingFan)); $re->setCommand(3, new Command\GarageDoorOnCommand($garageDoor), new Command\GarageDoorOffCommand($garageDoor)); $re->setCommand(4, new Command\StereoOnWithCDCommand($stereo), new Command\StereoOffCommand($stereo)); echo $re; $re->onButtonWasPushed(0); $re->offButtonWasPushed(0); $re->onButtonWasPushed(1); $re->undoButtonWasPushed(); $re->offButtonWasPushed(1); $re->onButtonWasPushed(2); $re->undoButtonWasPushed(); $re->offButtonWasPushed(2); $re->onButtonWasPushed(3); $re->undoButtonWasPushed(); $re->offButtonWasPushed(3); $re->onButtonWasPushed(4); $re->offButtonWasPushed(4);