Esempio n. 1
0
        static void Main(string[] args)
        {
            ILampSwitchCentral lampSwitchCentral = new LampSwitchCentral();

            lampSwitchCentral.Attach(new LampSwitch(1));
            lampSwitchCentral.Attach(new LampSwitch(2));
            lampSwitchCentral.Attach(new LampSwitch(3));

            ILightState lightState = new LightState();

            lightState.CurrentState = false; // off

            lampSwitchCentral.SetState(lightState);
            lampSwitchCentral.Notify();

            lightState.CurrentState = true; // on

            lampSwitchCentral.SetState(lightState);
            lampSwitchCentral.Notify();
        }
Esempio n. 2
0
 public void SetState(ILightState s)
 {
     _lightState = s as LightState;
 }
Esempio n. 3
0
 public LampSwitchCentral()
 {
     _observers  = new List <ILampSwitch>();
     _lightState = new LightState();
 }