public Coffee MakeCoffee(List <CoffeeIngredient> ingredientList) { if (ingredientList == null || ingredientList.Count == 0) { return(new CustomCoffee()); } else if (CompareIngredientLists(ingredientList, Americano.Ingredients)) { return(new Americano()); } else if (CompareIngredientLists(ingredientList, Cappuccino.Ingredients)) { return(new Cappuccino()); } else if (CompareIngredientLists(ingredientList, Espresso.Ingredients)) { return(new Espresso()); } else if (CompareIngredientLists(ingredientList, Irish.Ingredients)) { return(new Irish()); } else // Custom Coffee { var coffee = new CustomCoffee(); coffee.AddIngredients(ingredientList); return(coffee); } }
public IDrink MixDrink(string name, Amount?sugar = null, Amount?milk = null, Strength?strength = null, TeaBlend?blend = null, CustomCoffee coffee = null) { // GetValueOrDefault == If not null then use or else use given value // Can't seem to get around case? Ask Martijn. IDrink drink = null; switch (name) { case "Coffee": drink = new StrengthDrinkDecorator(new Coffee(), strength.GetValueOrDefault(Strength.Normal)); break; case "Espresso": drink = new StrengthDrinkDecorator(new Espresso(), Strength.Strong); break; case "Capuccino": drink = new StrengthDrinkDecorator(new Capuccino(), Strength.Normal); break; case "Wiener Melange": drink = new StrengthDrinkDecorator(new WienerMelange(), Strength.Weak); break; case "Café au Lait": drink = new CafeAuLait(); break; case "Tea": drink = new TeaAdapter(blend.GetValueOrDefault(_defaultTeaBlend)); break; case "Chocolate": drink = new ChocolateAdapter(); break; case "Chocolate Deluxe": drink = new ChocolateDeluxeAdapter(); break; case "Custom": drink = new CustomViewCoffee(coffee); break; } if (sugar != null) { drink = new SugarDrinkDecorator(drink, sugar.GetValueOrDefault(Amount.Normal)); } if (milk != null) { drink = new MilkDrinkDecorator(drink, milk.GetValueOrDefault(Amount.Normal)); } return(drink); }
public CoffeeBuilder() { coffee = new CustomCoffee(); }