Ejemplo n.º 1
0
        public double BuildMealForUser(List <FoodMenuModel> selectedMealItems)
        {
            Console.WriteLine();
            Console.WriteLine("You Selected Below Meal Items");
            Console.WriteLine("_______________________________");
            MealBuilder mealBuilder = new MealBuilder();

            mealBuilder.PrepareMeal(selectedMealItems);
            mealBuilder.meal.ShowItems();
            var totalCost = mealBuilder.meal.GetCost();

            Console.WriteLine("Total Cost(Rs.): {0}", totalCost);
            return(totalCost);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This driver called that module which followed Builder Design Pattern
        /// </summary>
        /// <param name="selectedMealItems"></param>
        /// <returns></returns>
        public double BuildMealForUser(List <FoodMenuModel> selectedMealItems)
        {
            Console.WriteLine();
            Console.WriteLine("You Selected Below Meal Items");
            Console.WriteLine("_______________________________");
            MealBuilder mealBuilder = new MealBuilder();

            mealBuilder.PrepareMeal(selectedMealItems);
            mealBuilder.meal.ShowItems();
            var foodCost = mealBuilder.meal.GetCost();

            //Calculation of Tax
            var taxCalculationContext = new TaxCalculationContext(new OneStarTaxCalculator());
            var taxAmount             = taxCalculationContext.GetCalculatedTax(foodCost, 0.05, false);
            var totalCostofFood       = foodCost + taxAmount;

            Console.WriteLine("Total Cost(Rs.): {0}", totalCostofFood);
            Console.WriteLine("Total Tax(Rs.): {0}", taxAmount);
            return(totalCostofFood);
        }
Ejemplo n.º 3
0
        public double BuildMealForUser(List <FoodMenuModel> selectedMealItems)
        {
            Console.WriteLine("______________________________");
            Console.WriteLine("You selected those items:");
            Console.WriteLine("______________________________");
            MealBuilder mealBuilder = new MealBuilder();

            mealBuilder.PrepareMeal(selectedMealItems);
            mealBuilder.meal.ShowItems();
            var foodCost = mealBuilder.meal.ComputePrice();

            var delivery = new DeliveryTaxCalculator();
            var taxCalculationContext = new DeliveryTaxCalculationContext(delivery);

            Console.WriteLine($"Delivery fee: {delivery.deliveryTax} dollars");
            var taxAmount = taxCalculationContext.GetCalculatedTax(foodCost);

            Console.WriteLine($"Total cost: {taxAmount}");
            return(taxAmount);
        }