Exemple #1
0
        public static Meals GetMealClassWithDishType(int type, Meals template = null)
        {
            Meals meal = null;

            if (type == 1 || type == 6)
            {
                meal = new Meals();
            }
            if (type == 2)
            {
                meal = new Burger();
            }
            if (type == 3)
            {
                meal = new Pizza();
            }
            if (type == 4)
            {
                meal = new Pasta();
            }
            if (type == 5)
            {
                meal = new Steak();
            }
            if (type == 7)
            {
                meal = new Drinks();
            }
            if (template != null)
            {
                meal.Name        = template.Name;
                meal.Description = template.Description;
                meal.Sauce       = template.Sauce;
                meal.Price       = template.Price;
                meal.Id          = template.Id;
            }
            return(meal);
        }
Exemple #2
0
        public Meals CreateMeal()
        {
            string name = GetMealName();

            Console.WriteLine("Choose the type of the meal you want to create:");
            Console.WriteLine("1. Drink");
            Console.WriteLine("2. Burger");
            Console.WriteLine("3. Pizza");
            Console.WriteLine("4. Pasta");
            Console.WriteLine("5. Steak");
            Console.WriteLine("6. Starter");
            Console.WriteLine("7. Dessert");

            int   selected = int.Parse(Console.ReadLine());
            Meals meal     = null;

            if (selected == 1)
            {
                meal          = new Drinks();
                meal.Dishtype = 7;
            }

            if (selected == 2)
            {
                meal          = new Burger();
                meal.Dishtype = 2;
            }

            if (selected == 3)
            {
                meal          = new Pizza();
                meal.Dishtype = 3;
            }

            if (selected == 4)
            {
                meal          = new Pasta();
                meal.Dishtype = 4;
            }

            if (selected == 5)
            {
                meal          = new Steak();
                meal.Dishtype = 5;
            }

            if (selected == 6)
            {
                meal          = new Meals();
                meal.Dishtype = 1;
            }

            if (selected == 7)
            {
                meal          = new Meals();
                meal.Dishtype = 6;
            }

            if (meal.GetType() == typeof(Drinks))
            {
                Console.WriteLine("Is the drink alcoholic?");
                Console.WriteLine("Answer Y or N");
                bool alcoholic = GetYesOrNoFromUser();
                if (alcoholic != true)
                {
                    (meal as Drinks).isAlcoholic = true;
                }
                else
                {
                    (meal as Drinks).isAlcoholic = false;
                }

                Console.WriteLine("Give the drink amount in centilitres:");
                int amount = int.Parse(Console.ReadLine());
                (meal as Drinks).Amount = amount;
            }

            if (meal.GetType() == typeof(Burger))
            {
                Console.WriteLine("Give patty info:");
                (meal as Burger).Patty = StringChecker(Console.ReadLine());

                Console.WriteLine("Give cheese info:");
                (meal as Burger).Cheese = StringChecker(Console.ReadLine());

                Console.WriteLine("Give bun info:");
                (meal as Burger).Bun = StringChecker(Console.ReadLine());
            }

            if (meal.GetType() == typeof(Pizza))
            {
                Console.WriteLine("Give the pizza toppings:");
                (meal as Pizza).Toppings = StringChecker(Console.ReadLine());
            }

            if (meal.GetType() == typeof(Pasta))
            {
                Console.WriteLine("Give the pastatype:");
                (meal as Pasta).Pastatype = StringChecker(Console.ReadLine());

                Console.WriteLine("Give the meat:");
                (meal as Pasta).Meat = StringChecker(Console.ReadLine());

                (meal as Pasta).Sauce = GetSauce();
            }

            if (meal.GetType() == typeof(Steak))
            {
                Console.WriteLine("Give the type of the steak:");
                (meal as Steak).Steaktype = StringChecker(Console.ReadLine());

                Console.WriteLine("Give the side with the steak:");
                (meal as Steak).Side = StringChecker(Console.ReadLine());

                (meal as Steak).Sauce = GetSauce();
            }



            Console.WriteLine("Do you want to add a description to the dish?");
            Console.WriteLine("Answer Y or N");
            bool answer = GetYesOrNoFromUser();

            if (answer == true)
            {
                meal.Description = GetMealDescription();
            }


            GetAllergenFromUSer(meal);

            float price = GetPrice();

            meal.Name  = name;
            meal.Price = price;

            return(meal);
        }
Exemple #3
0
        public void ShowMealData(Meals meal)
        {
            Console.WriteLine();
            Console.WriteLine($"Id: {meal.Id}");
            Console.WriteLine($"{meal.Name}");
            if (meal.Description != null)
            {
                Console.WriteLine($"{meal.Description}");
            }
            Type type = meal.GetType();

            if (type == typeof(Burger))
            {
                Burger burger = (Burger)meal;
                Console.WriteLine($"Patty: {burger.Patty}");
                Console.WriteLine($"Cheese: {burger.Cheese}");
                Console.WriteLine($"Bun: {burger.Bun}");
            }

            if (type == typeof(Pizza))
            {
                Pizza pizza = (Pizza)meal;
                Console.WriteLine($"Toppings: {pizza.Toppings}");
            }

            if (type == typeof(Pasta))
            {
                Pasta pasta = (Pasta)meal;
                Console.WriteLine($"Type of pasta: {pasta.Pastatype}");
                Console.WriteLine($"Meat: {pasta.Meat}");
            }

            if (type == typeof(Steak))
            {
                Steak steak = (Steak)meal;
                Console.WriteLine($"Type: {steak.Steaktype}");
                Console.WriteLine($"Side: {steak.Side}");
            }

            if (type == typeof(Drinks))
            {
                Drinks drink = (Drinks)meal;
                Console.WriteLine($"Amout: {drink.Amount}cl");
                if (drink.isAlcoholic == true)
                {
                    Console.WriteLine("Alcoholic");
                }
                else
                {
                    Console.WriteLine("Non-Alcoholic");
                }
            }

            if (meal.Sauce != null)
            {
                Console.WriteLine($"Sauce: {meal.Sauce}");
            }

            foreach (var allergen in meal.Allergentypes)
            {
                if (allergen == Allergen.AllergenType.glutenFree)
                {
                    Console.WriteLine("This dish is gluten free, " + Allergen.allergenChars[allergen]);
                }

                else if (allergen == Allergen.AllergenType.lactoseFree)
                {
                    Console.WriteLine("This dish is lactose free, " + Allergen.allergenChars[allergen]);
                }

                else if (allergen == Allergen.AllergenType.milkFree)
                {
                    Console.WriteLine("This dish is milk free, " + Allergen.allergenChars[allergen]);
                }

                else if (allergen == Allergen.AllergenType.lowLactose)
                {
                    Console.WriteLine("This dish is low lactose, " + Allergen.allergenChars[allergen]);
                }
            }

            Console.WriteLine($"Price: {meal.Price}€");
        }