public void AddSodaToInventory(SodaTypesEnum sodaType, int quantity)
 {
     if (_inventory.ContainsKey(sodaType))
     {
         _inventory[sodaType] += quantity;
     }
     else
     {
         _inventory.Add(sodaType, quantity);
     }
 }
Example #2
0
        //Great potential for a Service, if we load price data from an external services
        private int GetPriceForSoda(SodaTypesEnum sodaType)
        {
            switch (sodaType)
            {
            case SodaTypesEnum.coke:
                return(20);

            default:
                return(15);
            }
        }
 public bool RemoveSodaFromInventory(SodaTypesEnum sodaType, int quantity = 1)
 {
     if (_inventory.ContainsKey(sodaType) && _inventory[sodaType] >= quantity)
     {
         Console.WriteLine("Giving " + sodaType + " out");
         _inventory[sodaType] -= quantity;
         return(true);
     }
     else
     {
         Console.WriteLine("No " + sodaType + " left.");
         return(false);
     }
 }