Esempio n. 1
0
        public static void Run()
        {
            var gumballMachine = new GumballMachineWithState(5);

            Console.WriteLine(gumballMachine);

            gumballMachine.InsertQuarter();
            gumballMachine.TurnCrank();

            Console.WriteLine(gumballMachine);

            gumballMachine.InsertQuarter();
            gumballMachine.TurnCrank();
            gumballMachine.InsertQuarter();
            gumballMachine.TurnCrank();

            Console.WriteLine(gumballMachine);

            gumballMachine.InsertQuarter();
            gumballMachine.TurnCrank();
            gumballMachine.InsertQuarter();
            gumballMachine.TurnCrank();
            gumballMachine.InsertQuarter();
            gumballMachine.TurnCrank();
            gumballMachine.InsertQuarter();
            gumballMachine.TurnCrank();
            gumballMachine.Refill(15);
            gumballMachine.InsertQuarter();
            gumballMachine.TurnCrank();
            gumballMachine.EjectQuarter();
        }
Esempio n. 2
0
 public SoldOutState(GumballMachineWithState gumballMachine)
 {
     _gumballMachine = gumballMachine;
 }
Esempio n. 3
0
 public HasQuarterState(GumballMachineWithState gumballMachine)
 {
     _gumballMachine = gumballMachine;
 }
Esempio n. 4
0
 public WinnerState(GumballMachineWithState gumballMachine)
 {
     _gumballMachine = gumballMachine;
 }