// Start is called before the first frame update void Start() { RemoteControlInvoker remoteControlInvoker = new RemoteControlInvoker(); BuildManager buildManager = new BuildManager(turret); BuildManagerMissile buildManagerMissile = new BuildManagerMissile(buildManager); BuildManagerTurret buildManagerTurret = new BuildManagerTurret(buildManager); remoteControlInvoker.AddCommand(1, buildManagerMissile); remoteControlInvoker.AddCommand(1, buildManagerTurret); remoteControlInvoker.AddCommand(2, buildManagerMissile); remoteControlInvoker.AddCommand(2, buildManagerTurret); remoteControlInvoker.AddCommand(3, buildManagerMissile); remoteControlInvoker.AddCommand(3, buildManagerTurret); remoteControlInvoker.AddCommand(4, buildManagerMissile); remoteControlInvoker.AddCommand(4, buildManagerTurret); remoteControlInvoker.AddCommand(5, buildManagerMissile); remoteControlInvoker.AddCommand(5, buildManagerTurret); remoteControlInvoker.DisplayCommands(); remoteControlInvoker.InvokeOrPressRemoteButton(0); remoteControlInvoker.InvokeOrPressRemoteButton(1); remoteControlInvoker.InvokeOrPressRemoteButton(2); remoteControlInvoker.InvokeOrPressRemoteButton(3); remoteControlInvoker.InvokeOrPressRemoteButton(4); remoteControlInvoker.InvokeOrPressRemoteButton(5); remoteControlInvoker.InvokeUndoOrPressUndoButton(); remoteControlInvoker.InvokeUndoOrPressUndoButton(); remoteControlInvoker.InvokeUndoOrPressUndoButton(); remoteControlInvoker.InvokeUndoOrPressUndoButton(); remoteControlInvoker.InvokeUndoOrPressUndoButton(); }
static void Main(string[] args) { var tv = new TV(); var remoteControl = new RemoteControlInvoker(); var tvOnCOmmand = new TVOnCommand(tv); var tvOffCOmmand = new TVOffCommand(tv); //Configure commands remoteControl.SetCommand(0, tvOnCOmmand); remoteControl.SetCommand(1, tvOffCOmmand); //Execute commands remoteControl.OnButtonPushed(0); remoteControl.OnButtonPushed(1); Console.ReadKey(); }