예제 #1
0
        public Package(string description, decimal price, PhysicalParameters physicalParameters, DeliveryDetails deliveryDetails)
        {
            Description        = description ?? throw new ArgumentNullException(nameof(description));
            DeliveryDetails    = deliveryDetails ?? throw new ArgumentNullException(nameof(deliveryDetails));
            PhysicalParameters = physicalParameters ?? throw new ArgumentNullException(nameof(physicalParameters));
            Price = price > 0 ? price : throw new ArgumentException($"{nameof(price)} cannot be less than zero", nameof(price));

            Status        = DeliveryStatus.NotSent;
            DeliveryPrice = CalculateDeliveryPrice(SizeCategory, WeightCategory);
            InvoiceNo     = GenerateInvoiceNo();
        }
예제 #2
0
        private SizeCategory GetSizeCategory(PhysicalParameters measure)
        {
            const double SmallLimit  = 0.2;
            const double MediumLimit = 0.5;
            const double LargeLimit  = 1;

            if (measure.Height <= SmallLimit && measure.Length <= SmallLimit && measure.Width <= SmallLimit)
            {
                return(SizeCategory.Small);
            }
            else if (measure.Height <= MediumLimit && measure.Length <= MediumLimit && measure.Width <= MediumLimit)
            {
                return(SizeCategory.Medium);
            }
            else if (measure.Height <= LargeLimit && measure.Length <= LargeLimit && measure.Width <= LargeLimit)
            {
                return(SizeCategory.Large);
            }
            else
            {
                return(SizeCategory.ExtraLarge);
            }
        }