private void BeverageDeclaration(IBeverage beverage) { Console.WriteLine($"Du fick en {beverage.GetType().Name} serverad i en {beverage.CupType}!"); Console.WriteLine("Dryckens innehåll: "); beverage.Ingredients.ForEach(ing => Console.WriteLine("\t" + ing)); this.Ingredients.Clear(); }
public void MakeBeverage(IBeverage selectedBeverage, bool sugarAdded = false, bool milkAdded = false) { IBeverage beverage = (IBeverage)Activator.CreateInstance(selectedBeverage.GetType()); if (sugarAdded) { beverage.AddIngredient(IngredientType.Sugar); } if (milkAdded) { beverage.AddIngredient(IngredientType.Milk); } int status = -1; foreach (var item in beverage.Ingredients) { switch (item) { case IngredientType.CoffeePowder: status = CoffeePowderContainer.GetDose(); break; case IngredientType.ChocolatePowder: status = ChocolatePowderContainer.GetDose(); break; case IngredientType.Milk: status = MilkContainer.GetDose(); break; case IngredientType.HotMilk: status = MilkContainer.GetDose(); break; case IngredientType.Sugar: status = SugarContainer.GetDose(); break; default: status = 1; break; } if (status == -1) { break; } } if (status != -1) { dispensedBeverages.Add(beverage); OnDispensed($"Drink: {beverage.ToString()}"); } }