예제 #1
0
        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);
        }
예제 #2
0
        public void AddOrangeToSelectedCans()
        {
            OrangeSoda orange = new OrangeSoda();

            selectedCans.Add(orange);
            totalBill += orange.Cost;
        }
예제 #3
0
        public SodaMachineA()
        {
            register = new List <Coin>();
            cans     = new List <Can>();

            Quarter quarter = new Quarter();

            SetStartingMoney(20, quarter);

            Nickel nickel = new Nickel();

            SetStartingMoney(20, nickel);

            Penny penny = new Penny();

            SetStartingMoney(50, penny);

            Dime dime = new Dime();

            SetStartingMoney(10, dime);

            Cola cola = new Cola();

            SetStartingCans(10, cola);

            OrangeSoda orange = new OrangeSoda();

            SetStartingCans(10, orange);

            RootBeer rootbeer = new RootBeer();

            SetStartingCans(10, rootbeer);
        }
예제 #4
0
 public void RunSimulation(GrapeSoda grape, OrangeSoda orange, LemonSoda lemon)
 {
     Customer.DisplayUserAvailibleMoney();
     CanSodaMachine.DisplayCurrentInventoryWithPrice(grape, orange, lemon);
     UserInput(grape, orange, lemon);
     Console.ReadLine();
 }
예제 #5
0
        public static string PickASoda()
        {
            Console.WriteLine("Select a can of soda you would like to buy by entering the number assosiated with it: \n" + "--- ( 1 ) = Cola --- \n" + "--- ( 2 ) = OrangeSoda --- \n" + "--- ( 3 ) = RootBeer --- \n");
            ConsoleKeyInfo thing = Console.ReadKey();
            Can            can;

            if (thing.Key == ConsoleKey.D1)
            {
                can = new Cola("Cola");
                Console.WriteLine(" You picked a nice refreshing Cola!");
                return("Cola");
            }
            else if (thing.Key == ConsoleKey.D2)
            {
                can = new OrangeSoda("OrangeSoda");
                Console.WriteLine(" You picked cool can of OrangeSoda!");
                return("OrangeSoda");
            }
            else if (thing.Key == ConsoleKey.D3)
            {
                can = new RootBeer("RootBeer");
                Console.WriteLine(" You picked a nice cold RootBeer!");
                return("RootBeer");
            }
            else
            {
                Console.WriteLine("Please select again..");
                return("nothing");
            }
        }
예제 #6
0
        public void UserInput(GrapeSoda grapeSoda, OrangeSoda orangeSoda, LemonSoda lemonSoda)
        {
            Console.WriteLine("Pick a soda: Type 1 for Grapesoda, 2 for Orangesoda, or 3 for Lemonsoda");
            string userInput = Console.ReadLine();

            if (userInput == "1" && Customer.Wallet.Money >= grapeSoda.Value && CanSodaMachine.Inventory.GrapeSodas.Count > 0)
            {
                Customer.BuySoda(grapeSoda.Value);
                CanSodaMachine.Inventory.GrapeSodas.Remove(grapeSoda);
            }
            else if (userInput == "2" && Customer.Wallet.Money >= orangeSoda.Value && CanSodaMachine.Inventory.OrangeSodas.Count > 0)
            {
                Customer.BuySoda(orangeSoda.Value);
                CanSodaMachine.Inventory.OrangeSodas.Remove(orangeSoda);
            }
            else if (userInput == "3" && Customer.Wallet.Money >= lemonSoda.Value && CanSodaMachine.Inventory.LemonSodas.Count > 0)
            {
                Customer.BuySoda(lemonSoda.Value);
                CanSodaMachine.Inventory.LemonSodas.Remove(lemonSoda);
            }
            else
            {
                Console.WriteLine("wrong input");
                UserInput(grapeSoda, orangeSoda, lemonSoda);
            }
        }
예제 #7
0
 void FillBackBack()
 {
     can        = new List <Can>();
     orangeSoda = new OrangeSoda();
     rootBeer   = new RootBeer();
     cola       = new Cola();
 }
예제 #8
0
 public SodaMachine()
 {
     register          = new List <Coin>();
     inventory         = new List <Can>();
     temporaryRegister = new List <Coin>();
     for (int i = 0; i < 20; i++)
     {
         Quarter quarter = new Quarter();
         register.Add(quarter);
     }
     for (int i = 0; i < 10; i++)
     {
         Dime dime = new Dime();
         register.Add(dime);
     }
     for (int i = 0; i < 20; i++)
     {
         Nickle nickle = new Nickle();
         register.Add(nickle);
     }
     for (int i = 0; i < 50; i++)
     {
         Penny penny = new Penny();
         register.Add(penny);
     }
     for (int i = 0; i < 10; i++)
     {
         RootBeer   rootBeer   = new RootBeer();
         Cola       cola       = new Cola();
         OrangeSoda orangeSoda = new OrangeSoda();
         inventory.Add(cola);
         inventory.Add(rootBeer);
         inventory.Add(orangeSoda);
     }
 }
예제 #9
0
 private void FillOrangeSoda(int startingOrangeSoda)
 {
     for (int i = 0; i < startingOrangeSoda; i++)
     {
         OrangeSoda orangeSoda = new OrangeSoda();
         _inventory.Add(orangeSoda);
     }
 }
예제 #10
0
 private void StockOrangeSoda()
 {
     for (int i = 0; i < 10; i++)
     {
         OrangeSoda orangeSoda = new OrangeSoda();
         inventory.Add(orangeSoda);
     }
 }
예제 #11
0
 public void AddOrange(int count)
 {
     for (int i = 0; i < count; i++)
     {
         Can can = new OrangeSoda();
         inventory.Add(can);
     }
 }
예제 #12
0
 public void AddOrangeToInventory(int numberOfOrange)
 {
     for (int i = 0; i < numberOfOrange; i++)
     {
         OrangeSoda orange = new OrangeSoda();
         oranges.Add(orange);
     }
 }
예제 #13
0
 public void AddOrageSoda()
 {
     OrangeSodas = new List <OrangeSoda>();
     for (int i = 0; i < 6; i++)
     {
         OrangeSoda orangeSoda = new OrangeSoda();
         OrangeSodas.Add(orangeSoda);
     }
 }
예제 #14
0
        //A method to fill the sodamachines inventory with soda can objects.
        public void FillInventory()
        {
            Cola       cola       = new Cola();
            RootBeer   rootBeer   = new RootBeer();
            OrangeSoda orangeSoda = new OrangeSoda();

            AdministratorDepositCansIntoInventory(cola, 10);
            AdministratorDepositCansIntoInventory(rootBeer, 10);
            AdministratorDepositCansIntoInventory(orangeSoda, 1);
        }
 public void DisplayCurrentInventoryWithPrice(GrapeSoda grape, OrangeSoda orangeSoda, LemonSoda lemonSoda)
 {
     //Why does C# not print zero at the behinde the decimal point
     Console.WriteLine($"Gape cost:  ${grape.Value} cents");
     Console.WriteLine($"Organge cost:  ${orangeSoda.Value} cents");
     Console.WriteLine($"Lemon cost: ${lemonSoda.Value} cents");
     Console.WriteLine("Gape Soda in Inventory: " + Inventory.GrapeSodas.Count);
     Console.WriteLine("Orange Soda in Inventory: " + Inventory.OrangeSodas.Count);
     Console.WriteLine("Lemon Soda in Inventory: " + Inventory.LemonSodas.Count);
 }
예제 #16
0
 public void RemoveOrangeFromInventory()
 {
     if (oranges.Count > 0)
     {
         OrangeSoda orange = new OrangeSoda();
         oranges.Remove(orange);
     }
     else
     {
         Console.WriteLine("No Orange Soda Left.");
     }
 }
예제 #17
0
        //Soda machine starts with 20 of each kind of soda

        public void StartingCans()
        {
            for (int i = 0; i < 20; i++)
            {
                Cola       cola       = new Cola();
                OrangeSoda orangeSoda = new OrangeSoda();
                RootBeer   rootBeer   = new RootBeer();
                inventory.Add(cola);
                inventory.Add(orangeSoda);
                inventory.Add(rootBeer);
            }
        }
예제 #18
0
        static void Main(string[] args)
        {
            GrapeSoda  grape      = new GrapeSoda();
            OrangeSoda orangeSoda = new OrangeSoda();
            LemonSoda  lemonSoda  = new LemonSoda();
            //Customer customer = new Customer();
            //CanSodaMachine canSodaMachine = new CanSodaMachine();
            //customer.DisplayUserAvailibleMoney();
            //canSodaMachine.DisplayCurrentInventoryWithPrice(grape, orangeSoda, lemonSoda);
            //Console.ReadLine();
            Simulation simulation = new Simulation();

            simulation.RunSimulation(grape, orangeSoda, lemonSoda);
        }
예제 #19
0
        static void Main(string[] args)
        {
            SodaMachine testMachine  = new SodaMachine();
            Customer    testCustomer = new Customer();
            double      testDouble   = .20;
            Can         testCan      = new OrangeSoda();
            List <Coin> testList     = new List <Coin>();
            Wallet      testWallet   = new Wallet();

            //bool enoughMoneyForPurchase = testMachine.EnoughMoneyForPurchase(testDouble, testCan);
            //testMachine.ReturnMoneyToCustomer(testList, testCustomer);

            //testWallet.AddCoinstoWallet();
            //testMachine.AddCoinstoMachine();
        }
예제 #20
0
        public void AddCansToMachine()
        {
            //create a for loop to add the coins
            for (int i = 0; i < 10; i++)
            {
                OrangeSoda orangeSoda = new OrangeSoda();
                inventory.Add(orangeSoda);
                Cola cola = new Cola();
                inventory.Add(cola);
            }

            for (int i = 0; i < 7; i++)
            {
                Rootbeer rootbeer = new Rootbeer();
                inventory.Add(rootbeer);
            }
        }
예제 #21
0
 public void InitializeInventory()
 {
     for (int i = 0; i < 10; i++)
     {
         orangeSoda = new OrangeSoda();
         inventory.Add(orangeSoda);
     }
     for (int i = 0; i < 10; i++)
     {
         rootBeer = new RootBeer();
         inventory.Add(rootBeer);
     }
     for (int i = 0; i < 10; i++)
     {
         cola = new Cola();
         inventory.Add(cola);
     }
 }
예제 #22
0
        //member methods
        private void fillSodaMachine()
        {
            quarter    = new Quarter();
            dime       = new Dime();
            nickel     = new Nickel();
            penny      = new Penny();
            orangeSoda = new OrangeSoda();
            rootBeer   = new RootBeer();
            cola       = new Cola();
            Functions.CreateCans(cola, 5, inventory);
            Functions.CreateCans(orangeSoda, 9, inventory);
            Functions.CreateCans(rootBeer, 1, inventory);

            Functions.CreateCoins(quarter, 20, register); //20
            Functions.CreateCoins(dime, 10, register);    //10
            Functions.CreateCoins(nickel, 20, register);  //20
            Functions.CreateCoins(penny, 50, register);   //50
        }
예제 #23
0
 public void StartingInventory(int rootBeers, int colas, int orangeSodas)
 {
     for (int i = 0; i < rootBeers; i++)
     {
         RootBeer rootBeer = new RootBeer();
         inventory.Add(rootBeer);
     }
     for (int i = 0; i < colas; i++)
     {
         Cola cola = new Cola();
         inventory.Add(cola);
     }
     for (int i = 0; i < orangeSodas; i++)
     {
         OrangeSoda orangeSoda = new OrangeSoda();
         inventory.Add(orangeSoda);
     }
 }
예제 #24
0
 private void StartingCans()
 {
     for (int i = 0; i < 5; i++)
     {
         Cola cola = new Cola();
         cans.Add(cola);
     }
     for (int i = 0; i < 0; i++)
     {
         OrangeSoda orangeSoda = new OrangeSoda();
         cans.Add(orangeSoda);
     }
     for (int i = 0; i < 2; i++)
     {
         RootBeer rootBeer = new RootBeer();
         cans.Add(rootBeer);
     }
 }
예제 #25
0
 //A method to fill the sodamachines inventory with soda can objects.
 public void FillInventory()
 {
     for (int i = 0; i < 10; i++)
     {
         RootBeer rootBeer = new RootBeer();
         _inventory.Add(rootBeer);
     }
     for (int i = 0; i < 6; i++)
     {
         Cola cola = new Cola();
         _inventory.Add(cola);
     }
     for (int i = 0; i < 10; i++)
     {
         OrangeSoda orangeSoda = new OrangeSoda();
         _inventory.Add(orangeSoda);
     }
 }
예제 #26
0
        private double GetSodaCost(string soda)
        {
            Can can;

            switch (soda)
            {
            case "Cola":
                can = new Cola();
                return(can.Cost);

            case "Root Beer":
                can = new RootBeer();
                return(can.Cost);

            case "Orange Soda":
                can = new OrangeSoda();
                return(can.Cost);
            }
            return(-1);
        }
예제 #27
0
        //A method to fill the sodamachines inventory with soda can objects.
        public void FillInventory()
        {      // self note: what are we filling it with? sodas - orange soda, rootbeer, cola
            for (int i = 0; i <= 10; i++)
            {
                OrangeSoda orangeSoda = new OrangeSoda();
                _inventory.Add(orangeSoda);
            }

            for (int i = 0; i <= 10; i++)
            {
                RootBeer rootBeer = new RootBeer();
                _inventory.Add(rootBeer);
            }

            for (int i = 0; i <= 10; i++)
            {
                Cola cola = new Cola();
                _inventory.Add(cola);
            }
        }
예제 #28
0
        //A method to fill the sodamachines inventory with soda can objects.
        public void FillInventory()
        {
            Cola       cola     = new Cola();
            RootBeer   rootBeer = new RootBeer();
            OrangeSoda orange   = new OrangeSoda();

            for (int i = 0; i < 100; i++)
            {
                _inventory.Add(cola);
            }

            for (int i = 0; i < 100; i++)
            {
                _inventory.Add(rootBeer);
            }

            for (int i = 0; i < 100; i++)
            {
                _inventory.Add(orange);
            }
        }
예제 #29
0
        public static string SodaPrompt()
        {
            Can    cola     = new Cola();
            Can    rootbeer = new RootBeer();
            Can    orange   = new OrangeSoda();
            string output   = "";

            do
            {
                Console.WriteLine("Please choose a soda.");
                Console.WriteLine("1. " + cola.name);
                Console.WriteLine("2. " + rootbeer.name);
                Console.WriteLine("3. " + orange.name);
                int check = ValidInputNumeric(Console.ReadLine());
                if (check > 0 && check < 4)
                {
                    switch (check)
                    {
                    case 1:
                        output = cola.name;
                        break;

                    case 2:
                        output = rootbeer.name;
                        break;

                    case 3:
                        output = orange.name;
                        break;

                    default:
                        output = "";
                        break;
                    }
                }
            } while (output == "");
            return(output);
        }
예제 #30
0
        //Constructor (Spawner)
        public SodaMachine()
        {
            _register  = new List <Coin>();
            _inventory = new List <Can>();

            Quarter quarter = new Quarter();
            Dime    dime    = new Dime();
            Nickel  nickle  = new Nickel();
            Penny   penny   = new Penny();

            FillRegister(quarter, 20);
            FillRegister(dime, 10);
            FillRegister(nickle, 20);
            FillRegister(penny, 50);

            RootBeer   rootBeer   = new RootBeer();
            Cola       cola       = new Cola();
            OrangeSoda orangeSoda = new OrangeSoda();

            FillInventory(rootBeer, 10);
            FillInventory(cola, 10);
            FillInventory(orangeSoda, 10);
        }