public static double CalculateTotal(IEnumerable <OrderItem> orderItems) { double totalPrice = 0.0; foreach (var item in orderItems) { IDiscountCalculator discountCalculator = DiscountFactory.CreateDiscountCalculator(item.DiscountType); double itemPrice = discountCalculator.GetDiscountedPrice(item); totalPrice += itemPrice; } return(totalPrice); }