Пример #1
0
        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());
        }
Пример #2
0
        private IDrink GetDrink(string name, string brand)
        {
            IDrink drink = drinks
                           .FirstOrDefault
                               (d => d.Name == name && d.Brand == brand);

            return(drink);
        }
Пример #3
0
        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");
        }
Пример #4
0
        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");
        }
Пример #6
0
        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());
        }
Пример #7
0
 private void CheckRemainingPriceToPay()
 {
     if (RemainingPriceToPay == 0)
     {
         _selectedDrink.LogDrinkMaking(LogText);
         LogText.Add("------------------");
         _selectedDrink = null;
     }
 }
Пример #8
0
        public Order(Client client, IIngredient salad, IDessert dessert, IDrink drink)
        {
            Client  = client;
            Salad   = salad;
            Dessert = dessert;
            Drink   = drink;

            Client.Order = this;
        }
Пример #9
0
        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);
        }
Пример #11
0
 public void GetDrinkCharacteristics(IDrink drink)
 {
     Strong = drink.Strong;
     Amount = drink.Amount;
     drink.Ingredients.ForEach(ing =>
     {
         StrongModificator += ing.StrongModificator;
     });
 }
Пример #12
0
        // 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);
        }
Пример #13
0
        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);
        }
Пример #14
0
        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");
        }
Пример #16
0
        public HotChocolateDecorator(IDrink drink, bool deluxe) : base(drink)
        {
            Drink          = drink;
            chocolatedrink = new HotChocolate();

            if (deluxe)
            {
                chocolatedrink.MakeDeluxe();
            }
        }
Пример #17
0
 private void FinishMakingDrink()
 {
     if (_selectedDrink != null)
     {
         _selectedDrink.LogText(LogText);
         LogText.Add($"Finished making {_selectedDrink.Name}");
         LogText.Add("------------------");
         _selectedDrink = null;
     }
 }
Пример #18
0
        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);
        }
Пример #19
0
 /// <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);
     }
 }
Пример #20
0
        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;
            }
        }
Пример #21
0
        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);
        }
Пример #23
0
        /// <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);
        }
Пример #24
0
        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();
            }
        }
Пример #27
0
 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);
     }
 }
Пример #28
0
        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);
        }
Пример #29
0
        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);
        }
Пример #30
0
        public ChocolateDrinkDecorator(IDrink drink, bool isDeluxe) : base(drink)
        {
            hotChocolate = new HotChocolate();

            if (isDeluxe)
            {
                hotChocolate.MakeDeluxe();
            }

            this.Name  = hotChocolate.GetNameOfDrink();
            this.Price = hotChocolate.Cost();
        }
Пример #31
0
 /// <summary>
 /// The drink is passed by parameter.
 /// </summary>
 public SugarDecorator(IDrink drink)
 {
     _drink = drink;
 }
Пример #32
0
 public DrinkViewItem(IDrink source)
 {
     this.Source = source;
 }
Пример #33
0
 /// <summary>
 /// The drink is passed by parameter.
 /// </summary>
 public MilkDecorator(IDrink drink)
 {
     _drink = drink;
 }
Пример #34
0
 public Tom(IDrink service, IWallet wallet)
 {
     _drink = service;
     _wallet = wallet;
 }
Пример #35
0
 public Mike(IDrink service)
 {
     _drink = service;
 }