001package headfirst.command.undo;
002
003public class RemoteLoader {
004
005        public static void main(String[] args) {
006                RemoteControlWithUndo remoteControl = new RemoteControlWithUndo();
007
008                Light livingRoomLight = new Light("Living Room");
009
010                LightOnCommand livingRoomLightOn =
011                                new LightOnCommand(livingRoomLight);
012                LightOffCommand livingRoomLightOff =
013                                new LightOffCommand(livingRoomLight);
014
015                remoteControl.setCommand(0, livingRoomLightOn, livingRoomLightOff);
016
017                remoteControl.onButtonWasPushed(0);
018                remoteControl.offButtonWasPushed(0);
019                System.out.println(remoteControl);
020                remoteControl.undoButtonWasPushed();
021                remoteControl.offButtonWasPushed(0);
022                remoteControl.onButtonWasPushed(0);
023                System.out.println(remoteControl);
024                remoteControl.undoButtonWasPushed();
025
026                CeilingFan ceilingFan = new CeilingFan("Living Room");
027
028                CeilingFanMediumCommand ceilingFanMedium =
029                                new CeilingFanMediumCommand(ceilingFan);
030                CeilingFanHighCommand ceilingFanHigh =
031                                new CeilingFanHighCommand(ceilingFan);
032                CeilingFanOffCommand ceilingFanOff =
033                                new CeilingFanOffCommand(ceilingFan);
034
035                remoteControl.setCommand(0, ceilingFanMedium, ceilingFanOff);
036                remoteControl.setCommand(1, ceilingFanHigh, ceilingFanOff);
037
038                remoteControl.onButtonWasPushed(0);
039                remoteControl.offButtonWasPushed(0);
040                System.out.println(remoteControl);
041                remoteControl.undoButtonWasPushed();
042
043                remoteControl.onButtonWasPushed(1);
044                System.out.println(remoteControl);
045                remoteControl.undoButtonWasPushed();
046        }
047}