Esempio n. 1
0
        public static void Main(string[] args)
        {
            var ingredients = new List <Ingredient>
            {
                new Ingredient("Oil"),
                new Ingredient("Vegetables"),
                new Ingredient("Some meat"),
                new Ingredient("Spices"),
            };

            Dish soup = new Dish("Soup", 0.04);

            soup.IngredientsAdd(ingredients[1]);
            soup.IngredientsAdd(ingredients[2]);
            Dish salad = new Dish("Salad", 0.02);

            salad.IngredientsAdd(ingredients[0]);
            salad.IngredientsAdd(ingredients[1]);
            Dish steak = new Dish("Steak", 0.07);

            Console.WriteLine(soup.GetRecipe());
            Console.WriteLine(salad.GetRecipe());

            var soupPortions = new List <double>
            {
                200, 400, 600
            };
            var steakPortions = new List <double>
            {
                300, 500
            };
            var entry1      = new MenuEntry(salad, 500);
            var entry2      = new MenuEntry(soup, soupPortions);
            var entry3      = new MenuEntry(steak, steakPortions);
            var myPriceList = new PriceList(entry1);

            myPriceList.AddDish(entry2);
            myPriceList.AddDish(entry3);
            Console.WriteLine(myPriceList.Format());

            myPriceList.RemoveDish("Salad");
            Console.WriteLine(myPriceList.Format());

            var myOrder = new Order(entry3, myPriceList);

            myOrder.AddDish(entry2, 400, myPriceList);
            Console.WriteLine(myOrder.Format());

            myOrder.AddDish(entry2, 200, myPriceList);
            myOrder.RemoveDish("Steak");
            Console.WriteLine(myOrder.Format());
        }
Esempio n. 2
0
        static PriceList CreatePriceList()
        {
            PriceList ret;

            Console.Write("Enter discount code: ");
            switch (Console.ReadLine().ToLower())
            {
            case "":
                ret = new PriceList();
                break;

            case "25":
                Console.WriteLine("Code has been succesfully activated! -25%!");
                ret = new DiscountedPriceList(0.75);
                break;

            case "50":
                Console.WriteLine("Code has been succesfully activated! -50%!");
                ret = new DiscountedPriceList(0.50);
                break;

            default:
                Console.WriteLine("Invalid code. :(");
                ret = new PriceList();
                break;
            }

            Dish steakWithMashedPotatoes = Dish.Builder()
                                           .AddIngredient(new Ingredient("Beef", 300.0))
                                           .AddIngredient(new Ingredient("Potato", 250.0))
                                           .Build("Steak with mashed potatoes");

            Dish chickenSoup = Dish.Builder()
                               .AddIngredient(new Ingredient("Chicken", 150.0))
                               .AddIngredient(new Ingredient("Onion", 50.0))
                               .AddIngredient(new Ingredient("Potato", 140.0))
                               .AddIngredient(new Ingredient("Sour cream", 60.0))
                               .AddIngredient(new Ingredient("Water", 300.0))
                               .Build("Chicken soup");

            Dish vegetableSalad = Dish.Builder()
                                  .AddIngredient(new Ingredient("Tomatoes", 80.0))
                                  .AddIngredient(new Ingredient("Cucumbers", 80.0))
                                  .AddIngredient(new Ingredient("Onion", 30.0))
                                  .AddIngredient(new Ingredient("Pepper", 40.0))
                                  .Build("Vegetables salad");

            return(ret
                   .AddDish(steakWithMashedPotatoes, 15.0)
                   .AddDish(chickenSoup, 5.0)
                   .AddDish(vegetableSalad, 3.0));
        }