using System.Numerics; using ShippingCosts.Contracts; namespace ShippingCosts.Implementations; /// /// A package with dimensions and weight /// /// public sealed class Package : IMeasuredBox { private readonly int _width; private readonly int _height; private readonly int _depth; private readonly double _weight; public int Width { get => _width; init => _width = SanitizeValue(value); } public int Height { get => _height; init => _height = SanitizeValue(value); } public int Depth { get => _depth; init => _depth = SanitizeValue(value); } public double Weight { get => _weight; init => _weight = SanitizeValue(value); } private static T SanitizeValue(T value) where T : INumber => value > T.Zero ? value : T.Zero; }