コード例 #1
0
        public decimal ComputePrice(PizzaOrder order)
        {
            decimal nonDiscounted = order.Pizzas.Sum(pizza => pizza.Price);
            decimal discountValue = discountPolicy(order);

            return(nonDiscounted - discountValue);
        }
コード例 #2
0
        public static decimal BuyOneGetOneFree(PizzaOrder order)
        {
            var pizzas = order.Pizzas;

            if (pizzas.Count < 2)
            {
                return(0m);
            }
            return(pizzas.Min(pizza => pizza.Price));
        }
コード例 #3
0
 public static decimal FiveDollarsOffStuffedCrust(PizzaOrder order)
 {
     return(order.Pizzas.Sum(pizza => pizza.Crust == Crust.Stuffed ? 5m : 0m));
 }
コード例 #4
0
        public static decimal FivePercentOffMoreThanFiftyDollars(PizzaOrder order)
        {
            decimal nonDiscounted = order.Pizzas.Sum(pizza => pizza.Price);

            return(nonDiscounted >= 50 ? nonDiscounted * 0.05m : 0m);
        }
コード例 #5
0
 public decimal ComputePolicy(PizzaOrder order)
 {
     return(policies.Max(policy => policy.Invoke(order)));
 }