Exemplo n.º 1
0
        //Takes in a string and returns a can of that type if available.
        //If stock does not contain that type of can, this will return null
        public Can PrepareCan(string canChoice)
        {
            Can actualCan = null;

            switch (canChoice)
            {
            case "Cola":
                Can cola = new Cola();
                if (ContainsCan(cola))
                {
                    actualCan = cola;
                }
                break;

            case "Orange Soda":
                Can orange = new OrangeSoda();
                if (ContainsCan(orange))
                {
                    actualCan = orange;
                }
                break;

            case "Root Beer":
                Can rootbeer = new RootBeer();
                if (ContainsCan(rootbeer))
                {
                    actualCan = rootbeer;
                }
                break;

            default:
                break;
            }
            return(actualCan);
        }
Exemplo n.º 2
0
        public static Can PickingSoda()
        {
            Console.WriteLine("\n\tPlease pick from the following Soda Options: ");
            Console.WriteLine("Press [0] for RootBeer $0.60");
            Console.WriteLine("Press [1] for Cola $0.35");
            Console.WriteLine("Press [2] for Orange $0.06");

            string inputFromUser = Console.ReadLine();

            Can userInput;

            switch (inputFromUser)
            {
            case "0":
                userInput = new RootBeer("RootBeer");
                return(userInput);

            case "1":
                userInput = new Cola("Cola");
                return(userInput);

            case "2":
                userInput = new Orange("Orange");
                return(userInput);

                //come back for valiation
            }
            Console.WriteLine("Invalid Response");
            return(null);
        }
        //Properties

        //Constructor
        public SodaMachine()
        {
            register  = new List <Coin>();
            inventory = new List <Can>();

            if (register.Count < 100)
            {
                while (register.Count < 20)
                {
                    Quarter quarter = new Quarter();
                    register.Add(quarter);
                }
                while (register.Count >= 20 && register.Count < 30)
                {
                    Dime dime = new Dime();
                    register.Add(dime);
                }
                while (register.Count >= 30 && register.Count < 50)
                {
                    Nickel nickel = new Nickel();
                    register.Add(nickel);
                }
                while (register.Count >= 50 && register.Count < 100)
                {
                    Penny penny = new Penny();
                    register.Add(penny);
                }
            }
            if (inventory.Count < 50)
            {
                while (inventory.Count < 15)
                {
                    Cola cola = new Cola();
                    inventory.Add(cola);
                }
                while (inventory.Count >= 15 && inventory.Count < 30)
                {
                    OrangeSoda orangeSoda = new OrangeSoda();
                    inventory.Add(orangeSoda);
                }
                while (inventory.Count >= 30 && inventory.Count < 50)
                {
                    RootBeer rootBeer = new RootBeer();
                    inventory.Add(rootBeer);
                }
            }
        }