コード例 #1
0
        public static RemoteControl MakeRemote()
        {
            LightReceiver          light = new LightReceiver();
            AirconditionerReceiver AC    = new AirconditionerReceiver();

            Command lightOnCommand  = new LightOnCommand(light);
            Command lightOffCommand = new LightOffCommand(light);
            Command acOnCommand     = new ACOnCommand(AC);
            Command acOffCommand    = new ACOffCommand(AC);

            MacroCommand partyCommand = new MacroCommand();

            partyCommand.AddCommand(lightOnCommand);
            partyCommand.AddCommand(acOnCommand);

            RemoteControl remote = new RemoteControl();

            remote.LightOnCommand           = lightOnCommand;
            remote.LightOffCommand          = lightOffCommand;
            remote.AirConditionerOffCommand = acOnCommand;
            remote.AirConditionerOnCommand  = acOffCommand;
            remote.macroCommand             = partyCommand;

            return(remote);
        }
コード例 #2
0
 public void LightOn()
 {
     LightOnCommand.Execute();
 }