예제 #1
0
 public double CountPricePerOne(FoodProduct product)
 {
     if (product.ContainsLactose)
     {
         return(product.BaseKgPrice * averageWeightInGrams / 1000 + 1);
     }
     else
     {
         return(product.BaseKgPrice * averageWeightInGrams / 1000 + 2);
     }
 }
예제 #2
0
 public double SellRequiredAmount(FoodProduct product, int quantity)
 {
     if (quantity > 10)
     {
         return(CountPricePerOne(product) * quantity * 0.9);
     }
     else
     {
         return(CountPricePerOne(product) * quantity);
     }
 }
 public double CountExpirationDiscount(FoodProduct product)
 {
     if (DateTime.Now >= product.ExpiryDate)
     {
         return(0.5);
     }
     else
     {
         return(0);
     }
 }
 public double AddMarshmallows(FoodProduct product)
 {
     if (product.IntendedFor == EatingHabits.Vegan)
     {
         return(0);
     }
     else
     {
         return(1.2);
     }
 }
 public double CountPrice(FoodProduct product)
 {
     if (product.IntendedFor == EatingHabits.Vegan)
     {
         return(product.BaseKgPrice + 8);
     }
     else if (product.IntendedFor == EatingHabits.Vegetarian)
     {
         return(product.BaseKgPrice + 6);
     }
     else if (!product.ContainsLactose)
     {
         return(product.BaseKgPrice + 4);
     }
     else
     {
         return(product.BaseKgPrice + 2);
     }
 }
예제 #6
0
 public bool IsSuitableForNonMeatEaters(FoodProduct product)
 {
     return(suitabilityRealisation.IsSuitableForNonMeatEaters(product));
 }
예제 #7
0
 public bool IsSuitableForLactoseIntolerantPeople(FoodProduct product)
 {
     return(suitabilityRealisation.IsSuitableForLactoseIntolerantPeople(product));
 }
예제 #8
0
 public double AddSprinkles(FoodProduct product)
 {
     return(decoratingRealisation.AddSprinkles(product));
 }
예제 #9
0
 public double AddMarshmallows(FoodProduct product)
 {
     return(decoratingRealisation.AddMarshmallows(product));
 }
 public double AddSprinkles(FoodProduct product)
 {
     return(0.5);
 }
예제 #11
0
 public double CountPricePer200g(FoodProduct product)
 {
     return(product.BaseKgPrice * 0.2);
 }
예제 #12
0
 public double CountExpirationDiscount(FoodProduct product)
 {
     return(discountsRealisation.CountExpirationDiscount(product));
 }
 public bool IsSuitableForNonMeatEaters(FoodProduct product)
 {
     return(product.IntendedFor == EatingHabits.Vegan || product.IntendedFor == EatingHabits.Vegetarian);
 }
 public bool IsSuitableForLactoseIntolerantPeople(FoodProduct product)
 {
     return(!product.ContainsLactose);
 }
예제 #15
0
        static void Main(string[] args)
        {
            Client client = new Client(EatingHabits.Vegetarian, false);
            bool   productIsSuitableForLactoseIntolerant = false;
            bool   productIsSuitableForNonMeatEaters     = false;

            Console.WriteLine("Would you like:");
            Console.WriteLine("1 - a cake\r\n2 - a chocolate\r\n3 - a cupcake");
            Console.WriteLine("Enter your choice:");

            switch (GetIntInput(3))
            {
            case 1:
                FoodProduct cake        = new FoodProduct(EatingHabits.Vegetarian, new DateTime(2020, 12, 01), 17.5, false);
                CakeFactory cakeFactory = new CakeFactory(new SuitabilityForDifferentEatingHabits());

                if (client.EatingHabits == EatingHabits.Vegan || client.EatingHabits == EatingHabits.Vegetarian)
                {
                    productIsSuitableForNonMeatEaters = cakeFactory.IsSuitableForNonMeatEaters(cake);
                }
                if (!client.ToleratesLactose)
                {
                    productIsSuitableForLactoseIntolerant = cakeFactory.IsSuitableForLactoseIntolerantPeople(cake);
                }
                if (productIsSuitableForNonMeatEaters && productIsSuitableForLactoseIntolerant)
                {
                    Console.WriteLine("Cake price: " + cakeFactory.CountPrice(cake) + " eur");
                }
                else
                {
                    Console.WriteLine("This product is not suitable for you.");
                }
                break;

            case 2:
                FoodProduct      chocolate        = new FoodProduct(EatingHabits.Vegan, new DateTime(2021, 12, 01), 10.5, false);
                ChocolateFactory chocolateFactory = new ChocolateFactory(new HalfPriceDiscount());
                Console.WriteLine("Chocolate price: " + chocolateFactory.CountPricePer200g(chocolate) * (1 - chocolateFactory.CountExpirationDiscount(chocolate)) + " eur");
                break;

            case 3:
                FoodProduct    cupCake        = new FoodProduct(EatingHabits.Vegetarian, new DateTime(2020, 12, 01), 22.5, false);
                CupcakeFactory cupcakeFactory = new CupcakeFactory(new DecoratingWithToppings(), new SuitabilityForDifferentEatingHabits());
                double         toppingsPrice  = 0.0;
                Console.WriteLine("The price of one cupcake:" + cupcakeFactory.CountPricePerOne(cupCake) + " eur");

                if (client.EatingHabits == EatingHabits.Vegan || client.EatingHabits == EatingHabits.Vegetarian)
                {
                    productIsSuitableForNonMeatEaters = cupcakeFactory.IsSuitableForNonMeatEaters(cupCake);
                }
                if (!client.ToleratesLactose)
                {
                    productIsSuitableForLactoseIntolerant = cupcakeFactory.IsSuitableForLactoseIntolerantPeople(cupCake);
                }
                if (productIsSuitableForNonMeatEaters && productIsSuitableForLactoseIntolerant)
                {
                    Console.WriteLine("Would you like to add toppings?");
                    Console.WriteLine("1 - yes\r\n2 - no");
                    Console.WriteLine("Enter your choice:");
                    if (GetIntInput(3) == 1)
                    {
                        toppingsPrice = cupcakeFactory.AddMarshmallows(cupCake) + cupcakeFactory.AddSprinkles(cupCake);
                    }
                    else
                    {
                        toppingsPrice = 0.0;
                    }

                    Console.WriteLine("How many cupcakes would you like?");
                    Console.WriteLine("Enter your choice:");
                    int quantity = GetIntInput(200);
                    Console.WriteLine("Total price: " + (cupcakeFactory.SellRequiredAmount(cupCake, quantity) + toppingsPrice * quantity) + " eur");
                }
                else
                {
                    Console.WriteLine("This product is not suitable for you.");
                }

                break;

            default:
                Console.WriteLine("A problem occured.");
                break;
            }
        }