public static GreenState GetInstance() { if (_gsInstance == null) { _gsInstance = new GreenState(); } return(_gsInstance); }
/// <summary> /// Initializes a new instance of the <see cref="TrafficLight"/> class with specific state. /// Default - green. /// </summary> /// <param name="state">State of light of type <see cref="IState"/>.</param> public TrafficLight(IState state = null) { if (state == null) { state = new GreenState(); } this.State = state; }
// Use this for initialization void Start() { bulbs.Add("Red", objs[2]); bulbs.Add("Green", objs[0]); bulbs.Add("Yellow", objs[1]); greenState = new GreenState(this); redState = new RedState(this); yellowState = new YellowState(this); currentState = redState; m_timer = 0f; }
public Account(string owner) { _owner = owner; // set default state State = new GreenState(0.0, this); }
public IState Next(TrafficLight tl) { tl.CurrentLight = Light.Green; return(GreenState.GetInstance()); }