コード例 #1
0
 public WinnerState(GumballMachine machine)
 {
     _machine = machine;
 }
コード例 #2
0
 public GumballMonitor(GumballMachine machine)
 {
     _machine = machine;
 }
コード例 #3
0
        static void Main(string[] args)
        {
            string location = "Seattle";
            int count = 122;
            GumballMachine gumballMachine = new GumballMachine(location, count);
            GumballMonitor monitor = new GumballMonitor(gumballMachine);

            Console.WriteLine(gumballMachine);

            gumballMachine.InsertQuarter();
            gumballMachine.TurnCrank();
            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();

            Console.WriteLine(gumballMachine);

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

            Console.WriteLine(gumballMachine);

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

            Console.WriteLine(gumballMachine);

            monitor.Report();

            // Wait for user
            Console.ReadKey();
        }
コード例 #4
0
 public WinnerState(GumballMachine machine)
 {
     this._machine = machine;
 }
コード例 #5
0
 public SoldState(GumballMachine machine)
 {
     this._machine = machine;
 }
コード例 #6
0
 public NoQuarterState(GumballMachine machine)
 {
     this._machine = machine;
 }
コード例 #7
0
 public GumballMonitor(GumballMachine machine)
 {
     this._machine = machine;
 }