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 IDrink MakeDrink(string name, Strength strength, Amount sugar, Amount milk, Blend blend) { IDrink drink = new Drink(name, strength, sugar, milk, blend); switch (name) { case "Coffee": drink = new Coffee(drink); break; case "Espresso": drink = new Espresso(drink); break; case "Capuccino": drink = new Capuccino(drink); break; case "Wiener Melange": drink = new WienerMelange(drink); break; case "Café au Lait": drink = new CafeAuLait(drink); break; case "Chocolate": drink = new Chocolate(drink); break; case "Chocolate Deluxe": drink = new Chocolate(drink, true); break; case "Tea": drink = new Tea(drink); break; case "CoffeeChoc": drink = new Chocolate(new Coffee(drink)); break; case "IrishCoffee": drink = new CreamDecorator(new Whiskey(new Coffee(drink))); break; case "SpanishCoffee": drink = new CreamDecorator(new Cointreau(new Cognac(new Coffee(drink)))); break; case "ItalianCoffee": drink = new CreamDecorator(new Amaretto(new Coffee(drink))); break; } return(drink); }
private void SetupDrinkStrategies() { _drinks = new Dictionary <string, IDrink>(); _drinks["Coffee"] = new Coffee(_drinkStrength); _drinks["Espresso"] = new Espresso(); _drinks["Capuccino"] = new Capuccino(); _drinks["Wiener Melange"] = new WienerMelange(); _drinks["Café au Lait"] = new CafeAuLait(); _drinks["Chocolate"] = new HotChocolateAdapter(false); _drinks["Chocolate Deluxe"] = new HotChocolateAdapter(true); _drinks["Tea"] = new TeaAdapter(); _drinks["Special"] = new SpecialCoffeeAdapter(); }