Example #1
0
        public void Learn()
        {
            RemoteControl remoteControl = new RemoteControl();

            Light light = new Light();
            CeilingFan ceilingFan = new CeilingFan("");
            Stereo stereo = new Stereo();

            LightOnCommand lightOn = new LightOnCommand(light);
            LightOffCommand lightOff = new LightOffCommand(light);

            CeilingFanOnCommand ceilingFanOn = new CeilingFanOnCommand(ceilingFan);
            CeilingFanOffCommand ceilingFanOff = new CeilingFanOffCommand(ceilingFan);

            StereoOnWithCDCommand stereoOn = new StereoOnWithCDCommand(stereo);
            StereoOffCommand stereoOff = new StereoOffCommand(stereo);

            remoteControl.SetCommand(0, lightOn, lightOff);
            remoteControl.SetCommand(1, ceilingFanOn, ceilingFanOff);
            remoteControl.SetCommand(2, stereoOn, stereoOff);

            Console.WriteLine(remoteControl);

            remoteControl.OnButtonWasPushed(0);
            remoteControl.OffButtonWasPushed(0);

            remoteControl.OnButtonWasPushed(1);
            remoteControl.OffButtonWasPushed(1);

            remoteControl.OnButtonWasPushed(2);
            remoteControl.OffButtonWasPushed(2);
        }
Example #2
0
 public StereoOffCommand(Stereo stereo)
 {
     this.stereo = stereo;
 }
 public StereoOnWithCDCommand(Stereo stereo)
 {
     this.stereo = stereo;
 }