コード例 #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();
        }
コード例 #2
0
        static void Main(string[] args)
        {
            int    count    = 112;
            string location = "Seattle";

            GumballMachine gumballMachine = new GumballMachine(location, count);

            GumballMonitor gumballMonitor = new GumballMonitor(gumballMachine);

            gumballMonitor.Report();

            Console.ReadKey();
        }