static void Main(string[] args) { Pult pult = new Pult(); TV tv = new TV(); pult.SetCommand(new TVOnCommand(tv)); pult.PressButton(); pult.PressUndo(); Microwave microwave = new Microwave(); pult.SetCommand(new MicrowaveCommand(microwave, 5000)); pult.PressButton(); Console.Read(); }
static void Main(string[] args) { Pult pult = new Pult(); TV tv = new TV(); pult.SetCommand(new TVOnCommand(tv)); pult.PressButton(); pult.PressUndo(); EpsonCinema ec = new EpsonCinema(); pult.SetCommand(new EpsonCimemaOnCommand(ec)); pult.PressButton(); pult.PressUndo(); Console.Read(); }
static void Main(string[] args) { Pult invoker = new Pult(); TV reciver = new TV(); Command concreteCommand = new Command(reciver); invoker.SetCommand(concreteCommand); invoker.PressButton(); invoker.PressUndo(); }
static void Main(string[] args) { Pult pult = new Pult(); TV tv = new TV(); pult.SetCommand(new TVonCommand(tv)); pult.PressButton(); //включение pult.PressUndo(); //выключение Console.ReadKey(); }
static void Main(string[] args) { Pult pult = new Pult(); TV tv = new TV(); pult.SetCommand(new TVOnCommand(tv)); pult.PressButton(); pult.PressUndo(); Microwave microwave = new Microwave(); pult.SetCommand(new MicrowaveCommand(microwave, 5000)); pult.PressButton(); MacroCommand macro = new MacroCommand(new List <ICommand>() { new TVOnCommand(tv), new MicrowaveCommand(microwave, 5000) }); pult.SetCommand(macro); pult.PressButton(); }
public static void Main(string[] args) { // Объект пульта - инициатора комманды. Pult pult = new Pult(); // Принимающая сторона комманды. TV tv = new TV(); // Устанавливаем комманду и кому она будет отправляться. pult.SetCommand(new TVOnCommand(tv)); // Через нашу абстракцию пульт посылаем команды, нашей абстракции телевизору. pult.PressButton(); pult.PressUndo(); Console.Read(); }
/// <summary> /// The main. /// </summary> private static void Main() { var pult = new Pult(); var deviceA = new DeviceA(); pult.SetCommand(new OnAndOfCommand(deviceA)); pult.ExecuteCommand(); pult.RollBackCommand(); pult.SetCommand(new SelfTesting(deviceA, "Test 1")); pult.ExecuteCommand(); var deviceB = new DeviceB(); pult.SetCommand(new OnAndOfCommand(deviceB)); pult.ExecuteCommand(); pult.RollBackCommand(); pult.SetCommand(new SelfTesting(deviceB, "Test X")); pult.ExecuteCommand(); Console.ReadLine(); }