-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommandTest.php
More file actions
41 lines (29 loc) · 899 Bytes
/
Copy pathCommandTest.php
File metadata and controls
41 lines (29 loc) · 899 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?
namespace Command;
require_once './autoload.php';
$remote = new RemoteControlWithUndo();
$light = new Light();
$garage = new Garage();
$lightOn = new LightOnCommand($light);
$lightOff = new LightOffCommand($light);
$garageOpen = new GarageOpenCommand($garage);
$garageClose = new GarageCloseCommand($garage);
$stereo = new Stereo();
$stereoOn = new StereoOnWithCdCommand($stereo);
$stereoOff = new StereoOffCommand($stereo);
$remote->setCommand(0,$lightOn,$lightOff);
$remote->onButtonPushed(0);
$remote->undo();
$remote->offButtonPushed(0);
$remote->undo();
$remote->setCommand(1,$garageOpen,$garageClose);
$remote->onButtonPushed(1);
$remote->undo();
$remote->offButtonPushed(1);
$remote->undo();
$remote->setCommand(2,$stereoOn, $stereoOff);
$remote->onButtonPushed(2);
$remote->undo();
$remote->offButtonPushed(2);
$remote->undo();
echo $remote;