Beispiel #1
0
        public ParcelType(ParcelDimensions dimensions, double weightKg)
        {
            if (weightKg >= 50)
            {
                Name = "Heavy";
                Code = ParcelCode.Heavy;
                return;
            }

            var largestDimensionCm = dimensions.GetLargestDimension();

            if (largestDimensionCm < 10)
            {
                Name = "Small";
                Code = ParcelCode.Small;
            }
            else if (largestDimensionCm < 50)
            {
                Name = "Medium";
                Code = ParcelCode.Medium;
            }
            else if (largestDimensionCm < 100)
            {
                Name = "Large";
                Code = ParcelCode.Large;
            }
            else
            {
                Name = "XL";
                Code = ParcelCode.XL;
            }
        }
Beispiel #2
0
 public Parcel(double widthCm, double heightCm, double weightKg = 0)
 {
     Dimensions = new ParcelDimensions(widthCm, heightCm);
     Type       = new ParcelType(Dimensions, weightKg);
     WeightKg   = weightKg;
 }