Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            //initializing VendingMachine
            VendingMachine vm = new VendingMachine();

            vm.AddCoins(new Dictionary <int, int> {
                { 1, 100 }, { 5, 50 }, { 10, 50 }, { 25, 50 }
            });

            vm.AddItem(new Item {
                name = "pepsi", price = 70, count = 10
            });
            vm.AddItem(new Item {
                name = "coke", price = 85, count = 10
            });
            vm.AddItem(new Item {
                name = "water", price = 90, count = 10
            });
            Console.WriteLine("-----------------------INITIAL STATE---------------------------");
            vm.PrintCoins();
            vm.PrintItems();

            RunTest(vm, "pepsi", new Dictionary <int, int> {
                { 25, 3 }
            }, 1);
            RunTest(vm, "coke", new Dictionary <int, int> {
                { 25, 4 }, { 7, 3 }
            }, 2);
            RunTest(vm, "water", new Dictionary <int, int> {
                { 25, 3 }, { 10, 1 }, { 5, 1 }
            }, 3);
            RunTest(vm, "water", new Dictionary <int, int> {
                { 25, 3 }, { 10, 2 }, { 1, 2 }
            }, 4);
            RunTest(vm, "water", new Dictionary <int, int> {
                { 25, 3 }
            }, 5);
            RunTest(vm, "water", new Dictionary <int, int> {
                { 100000, 1 }
            }, 6);
            RunTest(vm, "apple", new Dictionary <int, int> {
                { 25, 1 }
            }, 7);

            Console.WriteLine();
            Console.WriteLine("Press enter key to end");
            Console.Read();
        }