public static void Run() { TvRemote remote = new TvRemote(new Television()); remote.VolumeUp.Press(); remote.VolumeDown.Press(); remote.On.Press(); remote.Off.Press(); }
static void Main(string[] args) { IElectronicDevice tv; var remote = TvRemote.GetDevice(DeviceType.TV); PowerButton pb = new PowerButton(remote); pb.Execute(); pb.Execute(); for (int i = 0; i < 30; i++) { pb.Volup(); } pb.Undo(); }
public static void FirstDemo() { IElectronicDevice newDevice = TvRemote.getDevice(); TurnTvOn onCommand = new TurnTvOn(newDevice); DeviceButton onPressed = new DeviceButton(onCommand); onPressed.Press(); TurnTvOff offcommand = new TurnTvOff(newDevice); onPressed = new DeviceButton(offcommand); onPressed.Press(); TurnTvUp upcommand = new TurnTvUp(newDevice); onPressed = new DeviceButton(upcommand); onPressed.Press(); onPressed.Press(); onPressed.Press(); }
private static void Sample2() { // We are now modeling the act of // picking up a remote, aiming it // at the TV, clicking the power // button and then watching as // the TV turns on and off // Pick up the TV remote IElectronicDevice TV = TvRemote.GetDevice(); // Create the power button PowerButton powBut = new PowerButton(TV); // Turn the TV on and off with each // press powBut.Execute(); TV.VolumeUp(); powBut.Undo(); }