Exemplo n.º 1
0
        private void UpdatePizzaUI()
        {
            if (pizzaType != PizzaType.Default)
            {
                pizza = pizza_factory.MakePizza(extrasList, pizzaType);


                PriceLabel.Content    = string.Format("{0}$", pizza.Price);
                CaloriesLabel.Content = pizza.Calories + " cal";

                ExtrasGroupBox.Visibility = Visibility.Visible;
            }

            if (PizzaList != null)
            {
                string pizza_label    = "Cart \n";
                double total_price    = 0;
                double total_calories = 0;

                foreach (IPizza pizza in PizzaList)
                {
                    pizza_label += string.Format("{0} \n", pizza.Name);

                    total_price += pizza.Price;

                    total_calories += pizza.Calories;
                }

                PizzaListLabel.Content = pizza_label;

                PriceTotalLabel.Content    = string.Format("{0}$", total_price);
                CaloriesTotalLabel.Content = total_calories + " cal";
            }
        }
 public override void Notify(string message)
 {
     if (pizza is null)
     {
         pizza = _pizzaFactory.MakePizza(_pizzaType, _pizza);
     }
     Console.WriteLine($"{GetType().Name} message: {message}");
 }
        public Pizza OrderPizza(PizzaType pizza)
        {
            var orderedPizza = pizzaFactory.MakePizza(pizza);

            orderedPizza.Prepare();
            orderedPizza.Bake();
            orderedPizza.Cut();
            orderedPizza.Box();

            return(orderedPizza);
        }
        private void UpdatePizzaUI()
        {
            if (pizzaType != null)
            {
                //Laver Pizza med toppings
                pizza = pizza_factory.MakePizza(extrasList, pizzaType);

                //Pris og Calorie label opdateres
                PriceLabel.Content    = string.Format("{0:C}", pizza.Price());
                CaloriesLabel.Content = pizza.Calories() + " kcal";

                ExtrasGroupBox.Visibility = Visibility.Visible;
            }

            if (PizzaList != null)
            {
                //Udskrive en listeoversigt med pizzaer
                string pizza_label    = "Kurv \n";
                double total_price    = 0;
                double total_calories = 0;

                foreach (IPizza pizza in PizzaList)
                {
                    pizza_label += string.Format("{0} \n", pizza.Name());

                    total_price += pizza.Price();

                    total_calories += pizza.Calories();
                }

                PizzaListLabel.Content = pizza_label;

                //Total pris og kalorier opdateres
                PriceTotalLabel.Content    = string.Format("{0:C}", total_price);
                CaloriesTotalLabel.Content = total_calories + " kcal";
            }
        }