Example #1
0
 public static GreenState GetInstance()
 {
     if (_gsInstance == null)
     {
         _gsInstance = new GreenState();
     }
     return(_gsInstance);
 }
Example #2
0
        /// <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;
        }
Example #3
0
 // 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;
 }
Example #4
0
 public Account(string owner)
 {
     _owner = owner;
     // set default state
     State = new GreenState(0.0, this);
 }
Example #5
0
 public IState Next(TrafficLight tl)
 {
     tl.CurrentLight = Light.Green;
     return(GreenState.GetInstance());
 }