Beispiel #1
0
        static void Main(string[] args)
        {
            GumballMachine gumballMachine = new GumballMachine(10);
            GumballMonitor gumballMonitor = new GumballMonitor(gumballMachine);

            gumballMonitor.Report();
        }
        static void Main(string[] args)
        {
            string machineName   = "Seatle";
            int    machineNumber = 112;

            Console.WriteLine("GumballMachine {0} {1}", machineName, machineNumber);

            GumballMachine gumballMachine = new GumballMachine(machineName, machineNumber);

            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();

            Console.ReadLine();
        }
Beispiel #3
0
        public static void Monitor()
        {
            Console.WriteLine("Wellcome to Gumball Machine");

            Console.Write("Gumball Machine name: ");

            var name = Console.ReadLine();

            Console.Write("Gumball Machine inventory: ");

            var inventory = int.Parse(Console.ReadLine());

            GumballMachine gumballMachine = new GumballMachine(name, inventory);

            GumballMonitor gumballMonitor = new GumballMonitor(gumballMachine);

            gumballMonitor.Report();
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            GumballMachine gumballMachine = new GumballMachine("Seattle", 5);
            GumballMonitor gumballMonitor = new GumballMonitor(gumballMachine);

            gumballMonitor.Report();

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

            gumballMonitor.Report();

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

            gumballMonitor.Report();

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

            gumballMonitor.Report();

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

            gumballMonitor.Report();

            gumballMachine.Refill(10);

            gumballMonitor.Report();
        }