Example #1
0
        public bool OrderCondiment(CondimentType condimentType, int quantity)
        {
            if (_currentCup == null)
            {
                return(false);
            }

            ICondimentService service = _condimentServiceFactory.Create(condimentType);

            if (!service.IsCondimentValid(quantity))
            {
                return(false);
            }

            if (_currentCup.Condiments.ContainsKey(condimentType))
            {
                _currentCup.Condiments.Remove(condimentType);
            }

            var condiment = service.OrderCondiment(quantity);

            _currentCup.Condiments.Add(condimentType, condiment);

            return(true);
        }
        public ICondimentService Create(CondimentType type)
        {
            switch (type)
            {
            case CondimentType.Cream:
                return(new CreamService(_appSettings));

            case CondimentType.Sugar:
                return(new SugarService(_appSettings));

            default:
                throw new Exception("Invalid condiment type");
            }
        }
 public void AddCondiment(CondimentType condimentType, double condimentPrice)
 {
     _price += condimentPrice;
     _condimentAdded.Add(condimentType);
     _description += $", { condimentType.ToString() }";
 }
 public virtual void AddCondiment(CondimentType condimentType, double condimentPrice)
 {
     _coffee.AddCondiment(condimentType, condimentPrice);
 }