Esempio n. 1
0
        public decimal CalculateTotal(Order order)
        {
            decimal currentTotal = 0;

            foreach (AbstractCalculator calculator in _calculators)
            {
                currentTotal = calculator.Calculate(currentTotal, order);
            }
            return currentTotal;
        }
Esempio n. 2
0
 private static decimal CalculateTotal(Order order)
 {
     decimal total = 0;
     foreach (OrderItem item in order.Items)
     {
         total += (item.Quantity * item.CostPerItem);
     }
     return total;
 }
Esempio n. 3
0
 public abstract decimal Calculate(decimal currentTotal, Order order);
Esempio n. 4
0
 public override decimal Calculate(decimal currentTotal, Order order)
 {
     return currentTotal + CalculateTotal(order);
 }
Esempio n. 5
0
        private decimal GetShippingTotal(Order order)
        {
            decimal shippingTotal = 0;

            foreach (OrderItem item in order.Items)
            {
                decimal itemShippingCost = ShippingCost * item.Quantity;
                if (item.IsFragile)
                {
                    itemShippingCost *= FragileShippingPremium;
                }
                shippingTotal += itemShippingCost;
            }
            return shippingTotal;
        }
Esempio n. 6
0
 public override decimal Calculate(decimal currentTotal, Order order)
 {
     return currentTotal + GetShippingTotal(order);
 }
Esempio n. 7
0
 private static bool IsNewZealand(Order order)
 {
     return (order.CountryCode == "NZ");
 }
Esempio n. 8
0
 public override decimal Calculate(decimal currentTotal, Order order)
 {
     if (IsNewZealand(order))
     {
         return (currentTotal * _gstRate);
     }
     return currentTotal;
 }