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)); }
public bool Validate(string type, bool hasSugar, bool hasMilk, Topping topping = null) { return(_drinkValidatorFactory.Get(type).Validate(type, hasSugar, hasMilk, topping)); }