public void OrderRistretto_WithMilkAndSugarAndChocolate() { AbstractAcuCafeFactory AcuCafeFactory = AcuCafeFactoryProducer.GetAcuCafeFactory(true); IDrink drinkFullOrder = AcuCafeAddInsRules.ProcessCoofeeAddIns(AcuCafeFactory.GetDrink(AcuCafeEnum.EnumDrinks.RISTRETTO), true, true, true); Assert.AreEqual("Ristretto, Chocolate, Sugar, Milk", drinkFullOrder.Prepare()); Assert.AreEqual(1.5 + 0.5 + 0.5 + 0.5, drinkFullOrder.Cost()); }
private IDrink GetDrink(string name, string brand) { IDrink drink = drinks .FirstOrDefault (d => d.Name == name && d.Brand == brand); return(drink); }
public string AddDrink(string type, string name, int servingSize, string brand) { IDrink drink = drinkFactory.CreateDrink(type, name, servingSize, brand); drinks.Add(drink); return($"Added {drink.Name} ({drink.Brand}) to the drink pool"); }
public void OrderExpresso() { AbstractAcuCafeFactory AcuCafeFactory = AcuCafeFactoryProducer.GetAcuCafeFactory(true); IDrink drinkOrder = AcuCafeFactory.GetDrink(AcuCafeEnum.EnumDrinks.EXPRESSO); Assert.AreEqual("Expresso", drinkOrder.Prepare()); Assert.AreEqual(1.8, drinkOrder.Cost()); }
public string AddDrink(string type, string name, int servingSize, string brand) { IDrink drink = this.drinkFactorie.CreateDrink(type, name, servingSize, brand); this.drinks.Add(drink); return($"Added {name} ({brand}) to the drink pool"); }
public void OrderRistretto() { AbstractAcuCafeFactory AcuCafeFactory = AcuCafeFactoryProducer.GetAcuCafeFactory(true); IDrink drinkOrder = AcuCafeFactory.GetDrink(AcuCafeEnum.EnumDrinks.RISTRETTO); Assert.AreEqual("Ristretto", drinkOrder.Prepare()); Assert.AreEqual(1.5, drinkOrder.Cost()); }
private void CheckRemainingPriceToPay() { if (RemainingPriceToPay == 0) { _selectedDrink.LogDrinkMaking(LogText); LogText.Add("------------------"); _selectedDrink = null; } }
public Order(Client client, IIngredient salad, IDessert dessert, IDrink drink) { Client = client; Salad = salad; Dessert = dessert; Drink = drink; Client.Order = this; }
public void TestEspressoWithMilkAndSugar() { AcuCafe cafe = new AcuCafe(_drinkFactory, _drinkIngredientFactory, _baristaInformer, _logger); IDrink d = cafe.OrderDrink("Espresso", new[] { "milk", "sugar" }); Assert.AreEqual(2.8, d.Cost()); Assert.AreEqual("Espresso with milk with sugar without chocolate topping", d.Description); Assert.IsTrue(d.IsValid); }
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 void GetDrinkCharacteristics(IDrink drink) { Strong = drink.Strong; Amount = drink.Amount; drink.Ingredients.ForEach(ing => { StrongModificator += ing.StrongModificator; }); }
// Zdarzenie obsługujące tworzenie obiektu napój private void DrinkClickEvent(object sender, EventArgs e) { Button button = sender as Button; IDrink drink = DrinkFactory.CreateDrink(button.Tag as FoodInformation); uiClbShopingCard.Items.Add(drink); _orderCost += drink.Price(); uiTxtOrderCost.Text = _orderCost.ToString("C", _cultureInfo); }
public void TestRuinedEspresso() { AcuCafe cafe = new AcuCafe(_drinkFactory, _drinkIngredientFactory, _baristaInformer, _logger); IDrink d = cafe.OrderDrink("Espresso", new[] { "milk", "sugar" }); d.AddIngredient(new DrinkIngredient("coconut", 0.5)); Assert.IsFalse(d.IsValid); }
public void TestPlainEspresso() { AcuCafe cafe = new AcuCafe(_drinkFactory, _drinkIngredientFactory, _baristaInformer, _logger); IDrink d = cafe.OrderDrink("Espresso", new string[] { }); Assert.AreEqual(1.8, d.Cost()); Assert.AreEqual("Espresso without milk without sugar without chocolate topping", d.Description); Assert.IsTrue(d.IsValid); }
public string AddDrink(string type, string name, int servingSize, string brand) { var classType = typeof(RestaurantController).Assembly.GetTypes().FirstOrDefault(x => x.Name == type); IDrink drink = (IDrink)Activator.CreateInstance(classType, new object[] { name, servingSize, brand }); this.drinks.Add(drink); return($"Added {name} ({brand}) to the drink pool"); }
public HotChocolateDecorator(IDrink drink, bool deluxe) : base(drink) { Drink = drink; chocolatedrink = new HotChocolate(); if (deluxe) { chocolatedrink.MakeDeluxe(); } }
private void FinishMakingDrink() { if (_selectedDrink != null) { _selectedDrink.LogText(LogText); LogText.Add($"Finished making {_selectedDrink.Name}"); LogText.Add("------------------"); _selectedDrink = null; } }
public IDrink CreateDrink(string drinkType, string name, int servingSize, string brand) { Type type = Assembly.GetCallingAssembly() .GetTypes() .FirstOrDefault(t => t.Name == drinkType); IDrink drink = (IDrink)Activator.CreateInstance(type, name, servingSize, brand); return(drink); }
/// <summary> /// process the selected addIns /// </summary> /// <param name="isCoffee"></param> private void ProcessAddIns(bool isCoffee) { if (isCoffee) { drinkOrder = AcuCafeAddInsRules.ProcessCoofeeAddIns(drinkOrder, ckbMilk.Checked, ckbSugar.Checked, ckbChocolate.Checked); } else { drinkOrder = AcuCafeAddInsRules.ProcessTeaAddIns(drinkOrder, ckbMilk.Checked, ckbSugar.Checked); } }
public void OnNext(Payment value) { _mainVM.LogText.Add($"Inserted {_mainVM.PaymentVM.LastInsertedMoney.ToString("C", CultureInfo.CurrentCulture)}, Remaining: {_mainVM.PaymentVM.RemainingPriceToPay.ToString("C", CultureInfo.CurrentCulture)}."); if (_mainVM.PaymentVM.RemainingPriceToPay == 0) { LogDrinkMaking(_mainVM.LogText); _mainVM.LogText.Add("------------------"); _drink = null; } }
static void Main(string[] args) { Console.WriteLine("Welcome to Starbuks!"); Console.WriteLine("What kind of drink do you want, sir?"); var drinkKind = Console.ReadLine(); IDrink drink = DrinksFactory.CreateDrink(drinkKind); Console.WriteLine($"Here's your drink, that gonna be {drink.Price()}"); Console.WriteLine("Thank oyu, sir!"); Console.ReadKey(); }
{ //string type, string name, int servingSize, string brand public IDrink CreateDrink(string typeDrink, string name, int servingSize, string brand) { Type typeClass = Assembly.GetCallingAssembly() .GetTypes() .FirstOrDefault(t => t.Name == typeDrink); IDrink food = (IDrink)Activator.CreateInstance( typeClass, name, servingSize, brand); return(food); }
/// <summary> /// Orders the drink. /// </summary> /// <param name="type">The type.</param> /// <param name="addOn">The add on.</param> /// <returns>IDrink implementation</returns> public static IDrink OrderDrink(DrinkType type, DrinkAddOn addOn) { IDrink drink = null; switch (type) { case DrinkType.Expresso: drink = new Expresso(); break; case DrinkType.Tea: drink = new Tea(); break; case DrinkType.IceTea: drink = new IceTea(); break; default: break; } if (drink != null) { if (type != DrinkType.IceTea) { if (addOn.HasMilk) { drink = new MilkDecorator(drink); } else { drink.Description += " without milk"; } } if (addOn.HasSugar) { drink = new SugarDecorator(drink); } else { drink.Description += " without sugar"; } if (addOn.HasChocolate && type == DrinkType.Expresso) { drink = new ChocolateDecorator(drink); } } drink.Description = $"We are preparing the following drink for you: {drink.Description}"; return(drink); }
private IDrink GetDrink(string name) { if (!_drinks.Keys.Contains(name)) { return(null); } IDrink drink = _drinks[name]; return(drink); }
public TeaDecorator(IDrink drink, string blendname) : base(drink) { Drink = drink; teadrink = new Tea(); teaBlendRepository = new TeaBlendRepository(); if (blendname != null) { teadrink.Blend = teaBlendRepository.GetTeaBlend(blendname); } }
public Chocolate(IDrink iDrink, bool isDeluxe = false) : base(iDrink) { Price = GetPrice(); Name = GetName(); MilkAmount = Amount.Extra; if (isDeluxe) { chocolate.MakeDeluxe(); } }
public static void Prepare(IDrink drink, IBaristaInformer informer) { if (drink.IsValid) { string message = "We are preparing the following drink for you: " + drink.Description; informer.Inform(message); } else { throw new Exception("We could not prepare the following drink: " + drink.Description); } }
public string AddDrink(string type, string name, int servingSize, string brand) { IDrink drink = DrinkFactory.GetDrink(type, name, servingSize, brand); if (!(drink is null)) { drinks.Add(drink); return($"Added {name} ({brand}) to the drink pool"); } return(null); }
public string AddDrink(string type, string name, int servingSize, string brand) { IDrink drink = DrinkFactory.Create(type, name, servingSize, brand); if (drink != null) { drinks.Add(drink); return($"Added {drink.Name} ({drink.Brand}) to the drink pool"); } return(string.Empty); }
public ChocolateDrinkDecorator(IDrink drink, bool isDeluxe) : base(drink) { hotChocolate = new HotChocolate(); if (isDeluxe) { hotChocolate.MakeDeluxe(); } this.Name = hotChocolate.GetNameOfDrink(); this.Price = hotChocolate.Cost(); }
/// <summary> /// The drink is passed by parameter. /// </summary> public SugarDecorator(IDrink drink) { _drink = drink; }
public DrinkViewItem(IDrink source) { this.Source = source; }
/// <summary> /// The drink is passed by parameter. /// </summary> public MilkDecorator(IDrink drink) { _drink = drink; }
public Tom(IDrink service, IWallet wallet) { _drink = service; _wallet = wallet; }
public Mike(IDrink service) { _drink = service; }