Пример #1
0
        private void CalculatePrice()
        {
            var totalPrice = 0.0;

            foreach (var parcel in _parcels.Values)
            {
                parcel.SetShippingPrice(ShippingRatesByCode);
                PriceDetails.AppendFormat($"{parcel.Name} parcel price : {parcel.TotalPrice}.\n");
                TotalPrice += parcel.TotalPrice;
            }

            ICalculateDiscounts orderDiscount = new object() as ICalculateDiscounts;

            Discounts = CalculateDiscounts(orderDiscount);

            TotalDiscount = Discounts.Sum(discount => discount.Value);

            TotalPrice -= TotalDiscount;

            if (Speedy)
            {
                SpeedyShippingPrice = totalPrice;
                TotalPrice         += SpeedyShippingPrice;
            }
        }
Пример #2
0
        public string PrintOrderPrice()
        {
            if (Speedy)
            {
                PriceDetails.AppendLine("=========== SpeedyShippingDelivery ===========");
                PriceDetails.AppendFormat($"Order price is {TotalPrice}\n\n");
                PriceDetails.AppendFormat("Order speedy price is {SpeedyShippingPrice}\n\n");
            }
            else
            {
                PriceDetails.AppendLine("=========== RegularShippingDelivery ===========");
                PriceDetails.AppendFormat($"Order price is {TotalPrice}\n\n");
            }
            PriceDetails.AppendFormat($"Total Discounts : {TotalDiscount}\n\n");

            return(PriceDetails.ToString());
        }