コード例 #1
0
ファイル: AcuCafe.cs プロジェクト: srivathsah/Acucafe
        public Tuple <string, Drink> OrderDrink(string type, bool hasMilk, bool hasSugar, Topping topping = null)
        {
            var message = string.Empty;
            var drink   = default(Drink);

            var drinkValidator = _drinkValidatorFactory.Get(type);

            if (drinkValidator == null)
            {
                message = _unableToProcess;
                return(new Tuple <string, Drink>(message, drink));
            }

            if (!drinkValidator.Validate(type, hasSugar, hasMilk, topping))
            {
                message = _unableToProcess;
                return(new Tuple <string, Drink>(message, drink));
            }

            drink = _drinkFactory.Get(type, hasSugar, hasMilk, topping);
            if (drink == null)
            {
                message = _unableToProcess;
                return(new Tuple <string, Drink>(message, drink));
            }

            message = drink.Prepare();
            return(new Tuple <string, Drink>(message, drink));
        }
コード例 #2
0
ファイル: DrinkValidator.cs プロジェクト: srivathsah/Acucafe
 public bool Validate(string type, bool hasSugar, bool hasMilk, Topping topping = null)
 {
     return(_drinkValidatorFactory.Get(type).Validate(type, hasSugar, hasMilk, topping));
 }