patterns/command/remoteundo/app.d

53 lines
2.1 KiB
D

module command.remoteundo.app;
import command.remoteundo.remotecontrol;
import command.remoteundo.lightoncommand;
import command.remoteundo.lightoffcommand;
import command.remoteundo.light;
import command.remoteundo.ceilingfan;
import command.remoteundo.ceilingfanoffcommand;
import command.remoteundo.ceilingfanoncommand;
import command.remoteundo.garagedoorupcommand;
import command.remoteundo.garagedoordowncommand;
import command.remoteundo.garagedoor;
import command.remoteundo.stereoonwithcdcommand;
import command.remoteundo.stereo;
import command.remoteundo.stereooffcommand;
import std.stdio : writeln;
void main()
{
auto remoteControl = new RemoteControl();
auto livingRoomLight = new Light("Living Room");
// auto kitchenLight = new Light("Kitchen");
// auto ceilingFan = new CeilingFan("Living Room");
// auto garageDoor = new GarageDoor("Garage");
// auto stereo = new Stereo("Living Room");
remoteControl.setCommand(0, new LightOnCommand(livingRoomLight), new LightOffCommand(livingRoomLight));
// remoteControl.setCommand(1, new LightOnCommand(kitchenLight), new LightOffCommand(kitchenLight));
// remoteControl.setCommand(2, new CeilingFanOnCommand(ceilingFan), new CeilingFanOffCommand(ceilingFan));
// remoteControl.setCommand(3, new StereoOnWithCDCommand(stereo), new StereoOffCommand(stereo));
// remoteControl.setCommand(4, new GarageDoorUpCommand(garageDoor), new GarageDoorDownCommand(garageDoor));
// writeln(remoteControl);
remoteControl.onButtonWasPushed(0);
remoteControl.offButtonWasPushed(0);
writeln(remoteControl);
remoteControl.undoButtonWasPushed();
remoteControl.offButtonWasPushed(0);
remoteControl.onButtonWasPushed(0);
writeln(remoteControl);
remoteControl.undoButtonWasPushed();
// remoteControl.onButtonWasPushed(1);
// remoteControl.offButtonWasPushed(1);
// remoteControl.onButtonWasPushed(2);
// remoteControl.offButtonWasPushed(2);
// remoteControl.onButtonWasPushed(3);
// remoteControl.offButtonWasPushed(3);
// remoteControl.onButtonWasPushed(4);
// remoteControl.offButtonWasPushed(4);
}