Пример #1
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);
            }
        }
Пример #2
0
 public void RunSimulation(GrapeSoda grape, OrangeSoda orange, LemonSoda lemon)
 {
     Customer.DisplayUserAvailibleMoney();
     CanSodaMachine.DisplayCurrentInventoryWithPrice(grape, orange, lemon);
     UserInput(grape, orange, lemon);
     Console.ReadLine();
 }
Пример #3
0
 //methods
 public void AddGrapeToInventory(int numberOfGrape)
 {
     for (int i = 0; i < numberOfGrape; i++)
     {
         GrapeSoda grape = new GrapeSoda();
         grapes.Add(grape);
     }
 }
Пример #4
0
 public void AddGrapeSoda()
 {
     GrapeSodas = new List <GrapeSoda>();
     for (int i = 0; i < 10; i++)
     {
         GrapeSoda grapeSoda = new GrapeSoda();
         GrapeSodas.Add(grapeSoda);
     }
 }
 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);
 }
Пример #6
0
 public void RemoveGrapeFromInventory()
 {
     if (grapes.Count > 0)
     {
         GrapeSoda grape = new GrapeSoda();
         grapes.Remove(grape);
     }
     else
     {
         Console.WriteLine("No Grape Soda Left.");
     }
 }
Пример #7
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);
        }