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(); }
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); } }