Beispiel #1
0
        public void Dispense()
        {
            Console.WriteLine("YOU'RE A WINNER! You get 2 gumballs for your quarter");
            _machine.ReleaseBall();
            var gumballsCount = _machine.GetCount();

            if (gumballsCount == 0)
            {
                _machine.SetState(_machine.GetSoldOutState());
            }
            else
            {
                _machine.ReleaseBall();
                gumballsCount = _machine.GetCount();
                if (gumballsCount > 0)
                {
                    _machine.SetState(_machine.GetNoQuarterState());
                }
                else
                {
                    Console.WriteLine("Oops, out of gumballs!");
                    _machine.SetState(_machine.GetSoldOutState());
                }
            }
        }
Beispiel #2
0
 public void Dispense()
 {
     _gumballMachine.ReleaseBall();
     if (_gumballMachine.GetCount() > 0)
     {
         _gumballMachine.SetState(_gumballMachine.GetNoQuarterState());
     }
     else
     {
         Console.WriteLine("Out of gumballs");
         _gumballMachine.SetState(_gumballMachine.GetSoldOutState());
     }
 }
Beispiel #3
0
 public void Dispense()
 {
     gumballMachine.ReleaseBall();
     if (gumballMachine.GetCount() > 0)
     {
         gumballMachine.SetState(gumballMachine.GetNoQuarterState());
     }
     else
     {
         System.Console.WriteLine("Oops, out of gumballs!");
         gumballMachine.SetState(gumballMachine.GetSoldOutState());
     }
 }
        public override void Dispense()
        {
            GumballMachine.ReleaseBall();

            if (GumballMachine.GetCount() > 0)
            {
                GumballMachine.SetState(GumballMachine.GetNoQuarterState());
            }
            else
            {
                GumballMachine.SetState(GumballMachine.GetSoldOutState());
            }
        }
        public void Dispense()
        {
            gumballMachine.ReleaseBall();

            if (gumballMachine.GetCount() > 0)
            {
                gumballMachine.SetState(gumballMachine.GetNoQuarterState());
            }
            else
            {
                view.DisplayMessage("Oops, out of gumballs.");
                gumballMachine.SetState(gumballMachine.GetSoldOutState());
            }
        }
Beispiel #6
0
        public void Dispense()
        {
            Console.WriteLine("You're a winner! You get 2 gumballs for your quarter");
            _gumballMachine.ReleaseBall();

            if (_gumballMachine.GetCount() == 0)
            {
                _gumballMachine.SetState(_gumballMachine.GetNoQuarterState());
            }
            else
            {
                _gumballMachine.ReleaseBall();
                if (_gumballMachine.GetCount() > 0)
                {
                    _gumballMachine.SetState(_gumballMachine.GetNoQuarterState());
                }
                else
                {
                    Console.WriteLine("Out of gumballs");
                    _gumballMachine.SetState(_gumballMachine.GetSoldOutState());
                }
            }
        }
Beispiel #7
0
        public void Dispense()
        {
            _machine.ReleaseBall();
            var gumballsCount = _machine.GetCount();

            if (gumballsCount > 0)
            {
                _machine.SetState(_machine.GetNoQuarterState());
            }
            else
            {
                Console.WriteLine("Oops, out of gumballs!");
                _machine.SetState(_machine.GetSoldOutState());
            }
        }
Beispiel #8
0
 public void Dispense()
 {
     Console.WriteLine("You are a WINNER! You get two gumballs for your quarter.");
     _gumballMachine.ReleaseBall();
     if (_gumballMachine.Count > 0)
     {
         _gumballMachine.ReleaseBall();
         if (_gumballMachine.Count > 0)
         {
             _gumballMachine.SetState(_gumballMachine.GetNoQuarterState());
         }
         else
         {
             Console.WriteLine("Oops, out of gumballs!");
             _gumballMachine.SetState(_gumballMachine.GetSoldOutState());
         }
     }
     else
     {
         _gumballMachine.SetState(_gumballMachine.GetSoldOutState());
     }
 }
Beispiel #9
0
 public void Dispense()
 {
     gumballMachine.ReleaseBall();
     if (gumballMachine.GetCount() == 0)
     {
         gumballMachine.SetState(gumballMachine.GetSoldOutState());
     }
     else
     {
         gumballMachine.ReleaseBall();
         System.Console.WriteLine("YOU’RE A WINNER! You got two gumballs for your quarter");
         if (gumballMachine.GetCount() > 0)
         {
             gumballMachine.SetState(gumballMachine.GetNoQuarterState());
         }
         else
         {
             System.Console.WriteLine("Oops, out of gumballs!");
             gumballMachine.SetState(gumballMachine.GetSoldOutState());
         }
     }
 }
Beispiel #10
0
        public override void Dispense()
        {
            Console.WriteLine("YOU ARE A WINNER! You get two gumballs for youre quarter");
            GumballMachine.ReleaseBall();

            if (GumballMachine.GetCount() == 0)
            {
                GumballMachine.SetState(GumballMachine.GetSoldOutState());
            }
            else
            {
                GumballMachine.ReleaseBall();
                if (GumballMachine.GetCount() > 0)
                {
                    GumballMachine.SetState(GumballMachine.GetNoQuarterState());
                }
                else
                {
                    Console.WriteLine("Oops out of gumballs!");
                    GumballMachine.SetState(GumballMachine.GetSoldOutState());
                }
            }
        }
Beispiel #11
0
 public void Dispense()
 {
     Console.ForegroundColor = ConsoleColor.Red;
     Console.WriteLine("YOU ARE A WINNER!!! You get two gumballs for your quarter");
     Console.ResetColor();
     _gumballMachine.ReleaseBall();
     if (_gumballMachine.GetCount() == 0)
     {
         _gumballMachine.SetState(_gumballMachine.GetSoldOutState());
     }
     else
     {
         _gumballMachine.ReleaseBall();
         if (_gumballMachine.GetCount() > 0)
         {
             _gumballMachine.SetState(_gumballMachine.GetNoQuarterState());
         }
         else
         {
             Console.WriteLine("Oops, out of gumballs!");
             _gumballMachine.SetState(_gumballMachine.GetSoldOutState());
         }
     }
 }
 public void EjectQuarter()
 {
     view.DisplayMessage("Quarter returned.");
     gumballMachine.SetState(gumballMachine.GetNoQuarterState());
 }
Beispiel #13
0
 public void EjectQuarter()
 {
     Console.WriteLine("Quarter returned");
     _machine.SetState(_machine.GetNoQuarterState());
 }
 public override void EjectQuarter()
 {
     Console.WriteLine("Quarter returned");
     GumballMachine.SetState(GumballMachine.GetNoQuarterState());
 }