module command.remoteundostatusmacro.app; import command.remoteundostatusmacro.remotecontrol; import command.remoteundostatusmacro.lightoncommand; import command.remoteundostatusmacro.lightoffcommand; import command.remoteundostatusmacro.light; import command.remoteundostatusmacro.tv; import command.remoteundostatusmacro.tvoffcommand; import command.remoteundostatusmacro.tvoncommand; import command.remoteundostatusmacro.hottub; import command.remoteundostatusmacro.hottuboffcommand; import command.remoteundostatusmacro.hottuboncommand; import command.remoteundostatusmacro.stereoonwithcdcommand; import command.remoteundostatusmacro.stereo; import command.remoteundostatusmacro.stereooffcommand; import command.remoteundostatusmacro.command; import command.remoteundostatusmacro.macrocommand; import std.stdio : writeln; void main() { auto remoteControl = new RemoteControl(); auto light = new Light("Living Room"); auto tv = new TV("Living Room"); auto stereo = new Stereo("Living Room"); auto hottub = new Hottub(); Command[] partyOn = cast(Command[])[ new LightOnCommand(light), new StereoOnWithCDCommand(stereo), new TVOnCommand(tv), new HottubOnCommand(hottub) ]; Command[] partyOff = cast(Command[])[ new LightOffCommand(light), new StereoOffCommand(stereo), new TVOffCommand(tv), new HottubOffCommand(hottub) ]; remoteControl.setCommand(0, new MacroCommand(partyOn), new MacroCommand(partyOff)); writeln(remoteControl); writeln("--- Pushing Macro On ---"); remoteControl.onButtonWasPushed(0); writeln("--- Pushing Macro Off ---"); remoteControl.offButtonWasPushed(0); writeln(remoteControl); remoteControl.undoButtonWasPushed(); writeln(remoteControl); remoteControl.onButtonWasPushed(0); writeln(remoteControl); }