示例#1
0
        static void Main(string[] args)
        {
            GumballMachine gumballMachine = new GumballMachine(5);

            Console.WriteLine(gumballMachine);

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

            Console.WriteLine(gumballMachine);

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

            Console.WriteLine(gumballMachine);

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

            Console.WriteLine(gumballMachine);

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

            Console.WriteLine(gumballMachine);
        }
示例#2
0
 public NoQuarterState(GumballMachine gumballMachine)
 {
     this.gumballMachine = gumballMachine;
 }
示例#3
0
 public SoldState(GumballMachine gumballMachine)
 {
     // TODO: Complete member initialization
     this.gumballMachine = gumballMachine;
 }
示例#4
0
 public WinnerState(GumballMachine gumballMachine)
 {
     this.gumballMachine = gumballMachine;
 }
示例#5
0
 public SoldState(GumballMachine gumballMachine)
 {
     this.gumballMachine = gumballMachine;
 }