Beispiel #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);
        }
Beispiel #2
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);
        }
Beispiel #3
0
 public StereoOffCommand(Stereo stereo)
 {
     this.stereo = stereo;
 }
Beispiel #4
0
 public StereoOnWithCDCommand(Stereo stereo)
 {
     this.stereo = stereo;
 }
Beispiel #5
0
 public StereoOffCommand(Stereo stereo)
 {
     this.stereo = stereo;
 }
 public StereoOnWithCDCommand(Stereo stereo)
 {
     this.stereo = stereo;
 }