Exemple #1
0
        /// <summary>
        /// Test with GumballMonitor. First argument should be location, second an int of gumballs
        /// </summary>
        public void RunTestV3(string[] args)
        {
            int count = 0;

            if (args.Length < 2)
            {
                Console.WriteLine("GumballMachine <name> <inventory>");
                Environment.Exit(1);
            }

            count = Int32.Parse(args[1]);



            GumballMachine machine = new GumballMachine(args[0], count);

            GumballMonitor monitor = new GumballMonitor(machine);

            Console.WriteLine(machine.ToString());

            machine.InsertQuarter();
            machine.TurnCrank();

            Console.WriteLine(machine.ToString());

            machine.InsertQuarter();
            machine.TurnCrank();
            machine.InsertQuarter();
            machine.TurnCrank();

            Console.WriteLine(machine.ToString());
            monitor.Report();
        }
        private void TestGumballMachineStates()
        {
            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.Write(gumballMachine);
        }
Exemple #3
0
        /// <summary>
        /// Test with WinnerState implemented
        /// </summary>
        public void RunTestV2()
        {
            GumballMachine machine = new GumballMachine("Test2", 5);

            Console.WriteLine(machine.ToString());

            machine.InsertQuarter();
            machine.TurnCrank();

            Console.WriteLine(machine.ToString());

            machine.InsertQuarter();
            machine.TurnCrank();
            machine.InsertQuarter();
            machine.TurnCrank();

            Console.WriteLine(machine.ToString());
        }
Exemple #4
0
        /// <summary>
        /// Simple test
        /// </summary>
        public void RunTestV1()
        {
            GumballMachine machine = new GumballMachine("Test1", 5);

            // Console.WriteLine(machine.ToString());
            //machine.Refill(10);
            Console.WriteLine(machine.ToString());

            machine.InsertQuarter();
            machine.EjectQuarter();
            machine.TurnCrank();

            Console.WriteLine(machine.ToString());

            machine.InsertQuarter();
            machine.TurnCrank();
            machine.InsertQuarter();
            machine.TurnCrank();
            machine.EjectQuarter();

            Console.WriteLine(machine.ToString());

            machine.InsertQuarter();
            machine.InsertQuarter();
            machine.TurnCrank();
            machine.InsertQuarter();
            machine.TurnCrank();
            machine.InsertQuarter();
            machine.TurnCrank();
            machine.EjectQuarter();

            Console.WriteLine(machine.ToString());
        }
        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.Write(gumballMachine);
            Console.ReadKey();
        }