コード例 #1
0
        public static void LeftInSodaMachine()
        {
            Console.WriteLine("What ya getting{OrangeSoda, RootBeer, Cola()");

            currentInventory = new List <Can>()
            {
                new OrangeSoda(), new RootBeer(), new Cola()
            };
            {
                for (int i = 0; i < 5; i--)
                {
                    Can orange = new OrangeSoda();
                    currentInventory.Remove(orange);
                }
                for (int i = 0; i < 11; i--)
                {
                    Can rbeer = new RootBeer();
                    currentInventory.Remove(rbeer);
                }
                for (int i = 0; i < 7; i--)
                {
                    Can cola = new Cola();
                    currentInventory.Remove(cola);
                }
            }
        }
コード例 #2
0
        public SodaMachine()
        {
            inventory = new List <Can>()
            {
                new OrangeSoda(), new RootBeer(), new Cola()
            };

            for (int i = 0; i < 5; i++)
            {
                Can orange = new OrangeSoda();
                inventory.Add(orange);
            }
            for (int i = 0; i < 11; i++)
            {
                Can rbeer = new RootBeer();
                inventory.Add(rbeer);
            }
            for (int i = 0; i < 7; i++)
            {
                Can cola = new Cola();
                inventory.Add(cola);
            }

            register = new List <Coin>()
            {
                new Quarter(), new Dime(), new Nickel(), new Penny()
            };

            for (int i = 0; i < 20; i++)
            {
                Coin quarter = new Quarter();
                register.Add(quarter);
            }
            for (int i = 0; i < 10; i++)
            {
                Coin dime = new Dime();
                register.Add(dime);
            }
            for (int i = 0; i < 20; i++)
            {
                Coin nickel = new Nickel();
                register.Add(nickel);
            }
            for (int i = 0; i < 50; i++)
            {
                Coin penny = new Penny();
                register.Add(penny);
            }
        }