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(); }
public void SetState(ILightState s) { _lightState = s as LightState; }
public LampSwitchCentral() { _observers = new List <ILampSwitch>(); _lightState = new LightState(); }