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