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.Read(); }
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) { TV tv = new TV(); Pult pult = new Pult(new TVOnCommand(tv)); pult.PressDoButton(); pult.PressUndoButton(); Console.ReadKey(); //pult can send any command to tv at the same time pult know nothing about just like tv //know nothing about pult //thus we have flexible system where all the commands are stored in one class }
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(); }
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) { var tv = new TV(); var airConditioning = new AirConditioning(); var tvOnCommand = new TvOnCommand(tv); var airStartCommand = new AirConditioningStartCommand(airConditioning, 21d); var pult = new Pult { BlueBtnCommand = tvOnCommand, RedBtnCommand = airStartCommand }; pult.BlueBtnPress(); pult.RedButtonPress(); 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(); }
/// <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(); }