Exemplo n.º 1
0
        static void Main(string[] args)
        {
            GumballMachine gbm = new GumballMachine(3);

            Console.WriteLine(gbm);
            gbm.InsertQuarter(); gbm.TurnCrank();

            Console.WriteLine(gbm);
            gbm.TurnCrank();

            Console.WriteLine(gbm);
            gbm.InsertQuarter(); gbm.TurnCrank();

            Console.WriteLine(gbm);
            gbm.InsertQuarter(); gbm.EjectQuarter(); gbm.TurnCrank();

            Console.WriteLine(gbm);
            gbm.InsertQuarter(); gbm.TurnCrank();

            Console.WriteLine(gbm);
            gbm.InsertQuarter(); gbm.TurnCrank();

            /*
                Mighty Gumball, Inc.
                C# Enabled Standing Gumball Model #2005
                Inventory: 3 gumballs
                Machine is waiting for quarter
                You inserted a quarter

                You turned...

                A gumball comes rolling out the slot...

                Mighty Gumball, Inc.
                C# Enabled Standing Gumball Model #2005
                Inventory: 2 gumballs
                Machine is waiting for quarter
                You turned but there's no quarter

                You need to pay first

                Mighty Gumball, Inc.
                C# Enabled Standing Gumball Model #2005
                Inventory: 2 gumballs
                Machine is waiting for quarter
                You inserted a quarter

                You turned...

                A gumball comes rolling out the slot...

                Mighty Gumball, Inc.
                C# Enabled Standing Gumball Model #2005
                Inventory: 1 gumball
                Machine is waiting for quarter
                You inserted a quarter

                Quarter returned

                You turned but there's no quarter

                You need to pay first

                Mighty Gumball, Inc.
                C# Enabled Standing Gumball Model #2005
                Inventory: 1 gumball
                Machine is waiting for quarter
                You inserted a quarter

                You turned...

                A gumball comes rolling out the slot...

                Oops, out of gumballs!

                Mighty Gumball, Inc.
                C# Enabled Standing Gumball Model #2005
                Inventory: 0 gumballs
                Machine is sold out
                You can't insert a quarter, the machine is sold out

                Sorry, you already turned the crank

                A gumball comes rolling out the slot...

                You turned, but there are no gumballs
             */

            string z = Console.ReadLine();
        }
Exemplo n.º 2
0
 public NoQuarterState(GumballMachine gumballMachine)
 {
     this.gumBallMachine = gumballMachine;
 }
Exemplo n.º 3
0
 public SoldState(GumballMachine gumballMachine)
 {
     this.gumBallMachine = gumballMachine;
 }
Exemplo n.º 4
0
 public HasQuarterState(GumballMachine gumballMachine)
 {
     this.gumballMachine = gumballMachine;
 }