const int NOT_PRESSED = 1;
set { _command = value; }
public void OnButtonWasPressed()
_command[PRESSED].Execute();
public void OffButtonWasPressed()
_command[NOT_PRESSED].Execute();
public class LightOnCommand : Command
public LightOnCommand(Light light)
public void Execute() { Console.WriteLine(_light.On()); }
public class LightOffCommand : Command
public LightOffCommand(Light light)
public void Execute() { Console.WriteLine(_light.Off()); }
public static void Main()
Light light = new Light();
LightOnCommand lightCommand = new LightOnCommand(light);
LightOffCommand lightOffCommand = new LightOffCommand(light);
Remote remote = new Remote();
remote.Command = new Command[] { lightCommand,lightOffCommand };
remote.OnButtonWasPressed();
remote.OffButtonWasPressed();