Beispiel #1
0
        public void AddIngredient(CoffeeIngredient ingredient)
        {
            if (ingredient == null)
            {
                throw new CoffeeException("Cannot add null ingredient!");
            }

            this.ingredients.Add(ingredient);
        }
Beispiel #2
0
        public IngredientInterface GetIngredient()
        {
            IngredientInterface res;
            string name  = NameBox.Text;
            double price = 0;

            double.TryParse(PriceBox.Text, out price);
            if (TypeBox.SelectedIndex == 0)
            {
                res = new CoffeeIngredient(name, price);
            }
            else
            {
                res = new Ingredient(name, price);
            }
            return(res);
        }
Beispiel #3
0
        public static IngredientInterface parseIngredient(string Name, string Price, string Type)
        {
            IngredientInterface ingredient = null;
            double price;

            if (Double.TryParse(Price, out price))
            {
                if (Type == "Ингредиент")
                {
                    ingredient = new Ingredient(Name, price);
                }
                else if (Type == "Кофе")
                {
                    ingredient = new CoffeeIngredient(Name, price);
                }
            }
            else
            {
                ingredient = new Ingredient("StockName", 10);
            }

            return(ingredient);
        }
 public ICoffeeBuilder AddIngredient(CoffeeIngredient ingredient)
 {
     coffee.AddIngredient(ingredient);
     return(this);
 }