static void Main(string[] args)
        {
            //Existing stuff in the house
            Light          bedRoomLights    = new Light();
            AirConditioner acForEntireHouse = new AirConditioner();

            //Create the ON commands
            LightOn          turnBedRoomLightsOn = new LightOn(bedRoomLights);
            AirConditionerOn turnOnAc            = new AirConditionerOn(acForEntireHouse);

            //Create the OFF commands
            LightOff          turnBedRoomLightOff = new LightOff(bedRoomLights);
            AirConditionerOff turnOffAc           = new AirConditionerOff(acForEntireHouse);

            //Add the ON to the remote
            RemoteController remote = new RemoteController();

            remote.InsertNewOnCommand(turnBedRoomLightsOn);
            remote.InsertNewOnCommand(turnOnAc);

            //Add the OFF to the remote
            remote.InsertNewOffCommand(turnBedRoomLightOff);
            remote.InsertNewOffCommand(turnOffAc);

            //Turn on the lights and AC
            remote.PressButtonOn(0);
            remote.PressButtonOn(1);

            //Turn off the lights and AC
            remote.PressButtonOff(0);
            remote.PressButtonOff(1);
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            //  Existing stuff in the house


            Light bedRoomLights = new Light();


            AC acForTheHouse = new AC();


            // CREATE the On cmd

            LightOn trunbedRoomLightsOn = new LightOn(bedRoomLights);


            ACOn trunOnAC = new ACOn(acForTheHouse);


            // CREATE the off cmd

            LightOff trunbedRoomLightsOff = new LightOff(bedRoomLights);


            ACOff trunOffAC = new ACOff(acForTheHouse);



            // add the On  / off to the Remote

            RemoteController remote = new RemoteController();

            remote.InsertNewOnCommand(trunbedRoomLightsOn);
            remote.InsertNewOnCommand(trunOnAC);


            remote.InsertNewOffCommand(trunbedRoomLightsOff);
            remote.InsertNewOffCommand(trunOffAC);


            // turn on the Light and AC

            remote.PressButonOn(0);
            remote.PressButonOn(1);

            // turn off both
            remote.PressButonOff(0);
            remote.PressButonOff(1);
        }