예제 #1
0
        static void Main(string[] args)
        {
            SodaMachine sodaMachine = SodaMachineSetup.New();

            Console.WriteLine($"Is {GrapeSodaCan.Name} in stock? {sodaMachine.isItemInStock(GrapeSodaCan.Name)}");

            List <Money> myPayment = new List <Money>();

            myPayment.Add(new Quarter());
            myPayment.Add(new Quarter());
            myPayment.Add(new Quarter());
            StockUnit myPurchase = sodaMachine.SellTranscation(GrapeSodaCan.Name, myPayment);

            Console.WriteLine(myPurchase.Description);
            Console.Read();
        }
예제 #2
0
        public static SodaMachine New()
        {
            SodaMachine      sodaMachine = new SodaMachine();
            List <Coin>      till        = new List <Coin>();
            List <StockUnit> items       = new List <StockUnit>();

            // Create 20 quarters
            for (int i = 0; i < 20; i++)
            {
                till.Add(new Quarter());
            }
            // Create 10 dimes
            for (int i = 0; i < 10; i++)
            {
                till.Add(new Dime());
            }
            // Create 20 nickels
            for (int i = 0; i < 20; i++)
            {
                till.Add(new Nickel());
            }
            // Create 50 pennies
            for (int i = 0; i < 50; i++)
            {
                till.Add(new Penny());
            }
            sodaMachine.AddCoin(till);

            // Create 20 grape sodas
            for (int i = 0; i < 20; i++)
            {
                items.Add(new GrapeSodaCan());
            }
            // Create 20 oragne sodas
            for (int i = 0; i < 20; i++)
            {
                items.Add(new OrangeSodaCan());
            }
            // Create 20 lemon sodas
            for (int i = 0; i < 20; i++)
            {
                items.Add(new LemonSodaCan());
            }
            sodaMachine.AddInventory(items);

            return(sodaMachine);
        }