コード例 #1
0
        protected bool IsOversized(IShippable prod)
        {
            var IsOversize = false;
            var girth      = (double)(prod.BoxLength + 2 * prod.BoxHeight + 2 * prod.BoxWidth);

            if (girth > 130)
            {
                //this is an oversize product
                IsOversize = true;
            }
            else
            {
                if (prod.BoxHeight > 108)
                {
                    IsOversize = true;
                }
                else if (prod.BoxLength > 108)
                {
                    IsOversize = true;
                }
                else if (prod.BoxWidth > 108)
                {
                    IsOversize = true;
                }
            }

            return(IsOversize);
        }
コード例 #2
0
        public string Add(IShippable item)
        {
            _counter++;
            shippable[_counter] = item;
            switch (item.Product)
            {
            case "Baseball Glove":
                _gloves++;
                break;

            case "Bicycle":
                _bikes++;
                break;

            case "Crackers":
                _crackers++;
                break;

            case "Lawn Mower":
                _mowers++;
                break;
            }
            return($"\n1 {shippable[_counter].Product} has been added\n" +
                   "Press any key to return to the menu. . .");
        }
コード例 #3
0
        protected bool IsOversized(IShippable prod)
        {
            bool   IsOversize = false;
            double girth      = (double)(prod.BoxLength + (2 * prod.BoxHeight) + (2 * prod.BoxWidth));

            if ((girth - 130 > 0))
            {
                //this is an oversize product
                IsOversize = true;
            }
            else
            {
                if (prod.BoxHeight > 108)
                {
                    IsOversize = true;
                }
                else if (prod.BoxLength > 108)
                {
                    IsOversize = true;
                }
                else if (prod.BoxWidth > 108)
                {
                    IsOversize = true;
                }
            }

            return(IsOversize);
        }
コード例 #4
0
        public void Add(IShippable item)
        {
            shoppingCart[shoppingCartIndex] = item;
            currentItem = item;
            shoppingCartIndex++;

            UpdateItemIndex(item);
        }
コード例 #5
0
ファイル: Shipper.cs プロジェクト: Zheikt/Howsden_Inventory
 public string Add(IShippable item)
 {
     for (int i = 0; i < 9; i++)
     {
         if (shipList[i] == null)
         {
             shipList[i] = item;
             return(item.Product);
         }
     }
     return(null);
 }
コード例 #6
0
 public void Add(string ProductType, int counter, int BicycleCounter, int LawnMowerCounter, int CrackersCounter, int BaseballGloveCounter)
 {
     IShippable[] Products = new IShippable[4];
     Products[0] = new Bicycles();
     Products[1] = new Lawn_Mowers();
     Products[2] = new Baseball_Gloves();
     Products[3] = new Crackers();
     //this resets the temporary counters, sets the temporary counters, and then returns them in main
     if (ProductType == Products[0].Product)
     {
         _counter        = 0;
         _BicycleCounter = 0;
         counter++;
         BicycleCounter++;
         _counter        += counter;
         _BicycleCounter += BicycleCounter;
     }
     if (ProductType == Products[1].Product)
     {
         _counter          = 0;
         _LawnMowerCounter = 0;
         counter++;
         LawnMowerCounter++;
         _counter          += counter;
         _LawnMowerCounter += LawnMowerCounter;
     }
     if (ProductType == Products[2].Product)
     {
         _counter = 0;
         _BaseballGloveCounter = 0;
         counter++;
         BaseballGloveCounter++;
         _counter += counter;
         _BaseballGloveCounter += BaseballGloveCounter;
     }
     if (ProductType == Products[3].Product)
     {
         _counter         = 0;
         _CrackersCounter = 0;
         counter++;
         CrackersCounter++;
         _counter         += counter;
         _CrackersCounter += CrackersCounter;
     }
 }
コード例 #7
0
 private void UpdateItemIndex(IShippable item)
 {
     if (item.Product == "Baseball Glove")
     {
         numBaseballGloves++;
     }
     else if (item.Product == "Bicycle")
     {
         numBicycles++;
     }
     else if (item.Product == "Lawn Mower")
     {
         numLawnMowers++;
     }
     else if (item.Product == "Crackers")
     {
         numCrackers++;
     }
 }
コード例 #8
0
        private bool IsOversized(IShippable prod)
        {
            decimal girth = (decimal)(prod.BoxLength + (2m * prod.BoxHeight) + (2m * prod.BoxWidth));

            if (GirthCheck)
            {
                if (girth > GirthMaxInInches)
                {
                    return(true);
                }
            }
            if (LengthPlusGirthCheck)
            {
                if ((girth + prod.BoxLength) > LengthPlusGirthMaxInInches)
                {
                    return(true);
                }
            }
            return(false);
        }
コード例 #9
0
        private bool IsOversized(IShippable prod)
        {
            var girth = 2m * prod.BoxHeight + 2m * prod.BoxWidth;

            if (GirthCheck)
            {
                if (girth > GirthMaxInInches)
                {
                    return(true);
                }
            }
            if (LengthPlusGirthCheck)
            {
                if (girth + prod.BoxLength > LengthPlusGirthMaxInInches)
                {
                    return(true);
                }
            }
            return(false);
        }
コード例 #10
0
        private void WriteSingleUPSPackage(ref XmlTextWriter xw, IShippable pak, bool ignoreDimensions)
        {
            decimal dGirth  = 0;
            decimal dLength = 0;
            decimal dHeight = 0;
            decimal dwidth  = 0;

            var dimensions = new List <DimensionAmount>();

            if (pak.BoxLengthType == LengthType.Centimeters)
            {
                dimensions.Add(new DimensionAmount(Conversions.CentimetersToInches(pak.BoxLength)));
                dimensions.Add(new DimensionAmount(Conversions.CentimetersToInches(pak.BoxWidth)));
                dimensions.Add(new DimensionAmount(Conversions.CentimetersToInches(pak.BoxHeight)));
            }
            else
            {
                dimensions.Add(new DimensionAmount(pak.BoxLength));
                dimensions.Add(new DimensionAmount(pak.BoxWidth));
                dimensions.Add(new DimensionAmount(pak.BoxWidth));
            }

            var sorted = (from d in dimensions
                          orderby d.Amount descending
                          select d.Amount).ToList();

            dLength = sorted[0];
            dwidth  = sorted[1];
            dHeight = sorted[2];

            dGirth = dwidth + dwidth + dHeight + dHeight;

            //--------------------------------------------
            // Package
            xw.WriteStartElement("Package");

            xw.WriteStartElement("PackagingType");

            var packageType = "02";

            if (GlobalSettings.DefaultPackaging != (int)PackagingType.Unknown)
            {
                packageType = ((int)GlobalSettings.DefaultPackaging).ToString();
                if (packageType.Trim().Length < 2)
                {
                    packageType = "0" + packageType;
                }
            }

            xw.WriteElementString("Code", packageType);
            xw.WriteElementString("Description", "Package");
            xw.WriteEndElement();

            //Dimensions can be skipped in latest UPS specs
            if (!ignoreDimensions)
            {
                if (dLength > 0 | dHeight > 0 | dwidth > 0)
                {
                    xw.WriteStartElement("Dimensions");
                    xw.WriteStartElement("UnitOfMeasure");
                    xw.WriteElementString("Code", "IN");
                    xw.WriteEndElement();
                    xw.WriteElementString("Length", Math.Round(dLength, 2).ToString(CultureInfo.InvariantCulture));
                    xw.WriteElementString("Width", Math.Round(dwidth, 2).ToString(CultureInfo.InvariantCulture));
                    xw.WriteElementString("Height", Math.Round(dHeight, 2).ToString(CultureInfo.InvariantCulture));
                    xw.WriteEndElement();
                }
            }

            if (pak.BoxWeight > 0)
            {
                xw.WriteStartElement("PackageWeight");
                xw.WriteStartElement("UnitOfMeasure");

                xw.WriteElementString("Code", pak.BoxWeightType == WeightType.Pounds ? "LBS" : "KGS");

                xw.WriteEndElement();
                xw.WriteElementString("Weight", Math.Round(pak.BoxWeight, 1).ToString(CultureInfo.InvariantCulture));
                xw.WriteEndElement();
            }
            else
            {
                xw.WriteStartElement("PackageWeight");
                xw.WriteStartElement("UnitOfMeasure");

                if (pak.BoxWeightType == WeightType.Pounds)
                {
                    xw.WriteElementString("Code", "LBS");
                }
                else
                {
                    xw.WriteElementString("Code", "KGS");
                }

                xw.WriteEndElement();
                xw.WriteElementString("Weight", Math.Round(0.1, 1).ToString(CultureInfo.InvariantCulture));
                xw.WriteEndElement();
            }

            if (ignoreDimensions == false)
            {
                // Oversize Checks
                var oversizeCheck = dGirth + dLength;
                if (oversizeCheck > 84)
                {
                    if (oversizeCheck < 108 & pak.BoxWeight < 30)
                    {
                        xw.WriteElementString("OversizePackage", "1");
                    }
                    else
                    {
                        if (pak.BoxWeight < 70)
                        {
                            xw.WriteElementString("OversizePackage", "2");
                        }
                        else
                        {
                            xw.WriteElementString("OversizePackage", "0");
                        }
                    }
                }
            }

            xw.WriteEndElement();
            // End Package
            //--------------------------------------------
        }
コード例 #11
0
 public string Add(IShippable shippable)
 {
     items.Add(shippable);
     return("1 " + shippable.Product + " has been added\n");
 }
コード例 #12
0
 //  Adds an item to the cart:
 public void Add(IShippable product)
 {
     cart.Add(product);
 }
コード例 #13
0
ファイル: Shipper.cs プロジェクト: Tomarik/Shopping-Cart
 public void Add(IShippable item)
 {
     cart.Add(item);
 }
コード例 #14
0
ファイル: UPSService.cs プロジェクト: KimRossey/MerchantTribe
        private List <IShippable> OptimizeSingleGroup(IShipment shipment)
        {
            const decimal MAXWEIGHT = 70;

            List <IShippable> result = new List <IShippable>();


            List <IShippable> itemsToSplit = new List <IShippable>();

            foreach (IShippable item in shipment.Items)
            {
                if (IsOversized(item))
                {
                    result.Add(item.CloneShippable());
                }
                else
                {
                    itemsToSplit.Add(item);
                }
            }


            IShippable tempPackage = new Shippable();

            foreach (IShippable pak in itemsToSplit)
            {
                if (MAXWEIGHT - tempPackage.BoxWeight >= pak.BoxWeight)
                {
                    // add to current box
                    tempPackage.BoxWeight            += pak.BoxWeight;
                    tempPackage.QuantityOfItemsInBox += pak.QuantityOfItemsInBox;
                    tempPackage.BoxValue             += pak.BoxValue;
                }
                else
                {
                    // Save the temp package if it has items
                    if (tempPackage.BoxWeight > 0 || tempPackage.QuantityOfItemsInBox > 0)
                    {
                        result.Add(tempPackage.CloneShippable());
                        tempPackage = new Shippable();
                    }

                    // create new box
                    if (pak.BoxWeight > MAXWEIGHT)
                    {
                        //Loop to break up > maxWeight Packages
                        int     currentItemsInBox = pak.QuantityOfItemsInBox;
                        decimal currentWeight     = pak.BoxWeight;

                        while (currentWeight > 0)
                        {
                            if (currentWeight > MAXWEIGHT)
                            {
                                IShippable newP = pak.CloneShippable();
                                newP.BoxWeight = MAXWEIGHT;
                                if (currentItemsInBox > 0)
                                {
                                    currentItemsInBox        -= 1;
                                    newP.QuantityOfItemsInBox = 1;
                                }
                                result.Add(newP);
                                currentWeight = currentWeight - MAXWEIGHT;
                                if (currentWeight < 0)
                                {
                                    currentWeight = 0;
                                }
                            }
                            else
                            {
                                // Create a new shippable box
                                IShippable newP = pak.CloneShippable();
                                newP.BoxWeight = currentWeight;
                                if (currentItemsInBox > 0)
                                {
                                    newP.QuantityOfItemsInBox = currentItemsInBox;
                                }
                                result.Add(newP);
                                currentWeight = 0;
                            }
                        }
                    }
                    else
                    {
                        tempPackage = pak.CloneShippable();
                    }
                }
            }

            // Save the temp package if it has items
            if (tempPackage.BoxWeight > 0 || tempPackage.QuantityOfItemsInBox > 0)
            {
                result.Add(tempPackage.CloneShippable());
                tempPackage = new Shippable();
            }

            return(result);
        }
コード例 #15
0
ファイル: UPSFreightService.cs プロジェクト: wncoder/core
        private CommodityType WriteSingleCommidityPackage(IShippable pak, bool ignoreDimensions)
        {
            decimal dGirth  = 0;
            decimal dLength = 0;
            decimal dHeight = 0;
            decimal dwidth  = 0;

            CommodityType      commodity = new CommodityType();
            CommodityValueType commValue = new CommodityValueType();

            commodity.NumberOfPieces = pak.QuantityOfItemsInBox.ToString();

            RateCodeDescriptionType packagingType = new RateCodeDescriptionType();

            packagingType.Code        = ((int)GlobalSettings.DefaultPackaging).ToString();
            packagingType.Description = GlobalSettings.DefaultPackaging.ToString();
            commodity.PackagingType   = packagingType;

            WeightType            weight            = new WeightType();
            UnitOfMeasurementType unitOfMeasurement = new UnitOfMeasurementType();

            unitOfMeasurement.Code        = (pak.BoxWeightType == Hotcakes.Shipping.WeightType.Pounds ? "LBS" : "KGS");
            unitOfMeasurement.Description = (pak.BoxWeightType == Hotcakes.Shipping.WeightType.Pounds ? "LBS" : "KGS");

            weight.UnitOfMeasurement = unitOfMeasurement;
            if (pak.BoxWeight > 0)
            {
                weight.Value = Math.Round(pak.BoxWeight, 1).ToString();
            }
            else
            {
                weight.Value = "1";
            }

            commodity.Weight       = weight;
            commodity.Description  = "Weight";
            commodity.FreightClass = GlobalSettings.FreightClass;


            var dimensions = new List <DimensionAmount>();

            if (pak.BoxLengthType == LengthType.Centimeters)
            {
                dimensions.Add(new DimensionAmount(Conversions.CentimetersToInches(pak.BoxLength)));
                dimensions.Add(new DimensionAmount(Conversions.CentimetersToInches(pak.BoxWidth)));
                dimensions.Add(new DimensionAmount(Conversions.CentimetersToInches(pak.BoxHeight)));
            }
            else
            {
                dimensions.Add(new DimensionAmount(pak.BoxLength));
                dimensions.Add(new DimensionAmount(pak.BoxWidth));
                dimensions.Add(new DimensionAmount(pak.BoxWidth));
            }

            var sorted = (from d in dimensions
                          orderby d.Amount descending
                          select d.Amount).ToList();

            dLength = sorted[0];
            dwidth  = sorted[1];
            dHeight = sorted[2];

            dGirth = dwidth + dwidth + dHeight + dHeight;
            //Dimensions can be skipped in latest UPS specs
            if (!ignoreDimensions)
            {
                if (dLength > 0 | dHeight > 0 | dwidth > 0)
                {
                    DimensionsType commondityDimensions = new DimensionsType();

                    commondityDimensions.Height = Math.Round(dHeight, 2).ToString(CultureInfo.InvariantCulture);
                    commondityDimensions.Width  = Math.Round(dwidth, 2).ToString(CultureInfo.InvariantCulture);
                    commondityDimensions.Length = Math.Round(dLength, 2).ToString(CultureInfo.InvariantCulture);

                    UnitOfMeasurementType unitOfMeasurementDimention = new UnitOfMeasurementType();
                    unitOfMeasurementDimention.Code        = "IN";
                    unitOfMeasurementDimention.Description = "Inch";
                    commondityDimensions.UnitOfMeasurement = unitOfMeasurementDimention;

                    commodity.Dimensions = commondityDimensions;
                }
            }
            return(commodity);
        }
コード例 #16
0
        protected bool IsOversized(IShippable prod)
        {
            bool IsOversize = false;
            double girth = (double)(prod.BoxLength + (2 * prod.BoxHeight) + (2 * prod.BoxWidth));
            if ((girth - 130 > 0))
            {
                //this is an oversize product
                IsOversize = true;
            }
            else
            {
                if (prod.BoxHeight > 108)
                {
                    IsOversize = true;
                }
                else if (prod.BoxLength > 108)
                {
                    IsOversize = true;
                }
                else if (prod.BoxWidth > 108)
                {
                    IsOversize = true;
                }
            }

            return IsOversize;
        }
コード例 #17
0
 public void Add(IShippable item)
 {
     this.items.Add(item);
 }
コード例 #18
0
ファイル: Shipper.cs プロジェクト: IanSchow/Schow_Inventory
 // Adding the newest product to the product array and increasing the counter keeping track of how full it is
 public void Add(IShippable product, int location)
 {
     ProductArray[location] = product;
     fillSize++;
 }
コード例 #19
0
ファイル: UPSService.cs プロジェクト: KimRossey/MerchantTribe
        private void WriteSingleUPSPackage(ref XmlTextWriter xw, IShippable pak, bool ignoreDimensions)
        {
            decimal dGirth = 0;
            decimal dLength = 0;
            decimal dHeight = 0;
            decimal dwidth = 0;

            List<DimensionAmount> dimensions = new List<DimensionAmount>();

            if (pak.BoxLengthType == LengthType.Centimeters)
            {
                dimensions.Add(new DimensionAmount(MerchantTribe.Web.Conversions.CentimetersToInches(pak.BoxLength)));
                dimensions.Add(new DimensionAmount(MerchantTribe.Web.Conversions.CentimetersToInches(pak.BoxWidth)));
                dimensions.Add(new DimensionAmount(MerchantTribe.Web.Conversions.CentimetersToInches(pak.BoxHeight)));
            }
            else
            {
                dimensions.Add(new DimensionAmount(pak.BoxLength));
                dimensions.Add(new DimensionAmount(pak.BoxWidth));
                dimensions.Add(new DimensionAmount(pak.BoxWidth));
            }

            List<decimal> sorted = (from d in dimensions
                                    orderby d.Amount descending
                                    select d.Amount).ToList();
            dLength = sorted[0];
            dwidth = sorted[1];
            dHeight = sorted[2];

            dGirth = dwidth + dwidth + dHeight + dHeight;

            //--------------------------------------------
            // Package
            xw.WriteStartElement("Package");

            xw.WriteStartElement("PackagingType");

            string packageType = "02";
            if ((GlobalSettings.DefaultPackaging != (int)PackagingType.Unknown))
            {
                packageType = ((int)GlobalSettings.DefaultPackaging).ToString();
                if (packageType.Trim().Length < 2)
                {
                    packageType = "0" + packageType;
                }
            }
            xw.WriteElementString("Code", packageType);
            xw.WriteElementString("Description", "Package");
            xw.WriteEndElement();

            //Dimensions can be skipped in latest UPS specs
            if (ignoreDimensions == false)
            {
                if (dLength > 0 | dHeight > 0 | dwidth > 0)
                {
                    xw.WriteStartElement("Dimensions");
                    xw.WriteStartElement("UnitOfMeasure");
                    xw.WriteElementString("Code", "IN");
                    xw.WriteEndElement();
                    xw.WriteElementString("Length", Math.Round(dLength, 2).ToString(System.Globalization.CultureInfo.InvariantCulture));
                    xw.WriteElementString("Width", Math.Round(dwidth, 2).ToString(System.Globalization.CultureInfo.InvariantCulture));
                    xw.WriteElementString("Height", Math.Round(dHeight, 2).ToString(System.Globalization.CultureInfo.InvariantCulture));
                    xw.WriteEndElement();
                }
            }

            if (pak.BoxWeight > 0)
            {
                xw.WriteStartElement("PackageWeight");
                xw.WriteStartElement("UnitOfMeasure");
                if (pak.BoxWeightType == WeightType.Pounds)
                {
                    xw.WriteElementString("Code", "LBS");
                }
                else
                {
                    xw.WriteElementString("Code", "KGS");
                }
                xw.WriteEndElement();
                xw.WriteElementString("Weight", Math.Round(pak.BoxWeight, 1).ToString(System.Globalization.CultureInfo.InvariantCulture));
                xw.WriteEndElement();
            }
            else
            {
                xw.WriteStartElement("PackageWeight");
                xw.WriteStartElement("UnitOfMeasure");
                if (pak.BoxWeightType == WeightType.Pounds)
                {
                    xw.WriteElementString("Code", "LBS");
                }
                else
                {
                    xw.WriteElementString("Code", "KGS");
                }

                xw.WriteEndElement();
                xw.WriteElementString("Weight", Math.Round(0.1, 1).ToString(System.Globalization.CultureInfo.InvariantCulture));
                xw.WriteEndElement();
            }

            if (ignoreDimensions == false)
            {
                // Oversize Checks
                decimal oversizeCheck = dGirth + dLength;
                if (oversizeCheck > 84)
                {
                    if (oversizeCheck < 108 & pak.BoxWeight < 30)
                    {
                        xw.WriteElementString("OversizePackage", "1");
                    }
                    else
                    {
                        if (pak.BoxWeight < 70)
                        {
                            xw.WriteElementString("OversizePackage", "2");
                        }
                        else
                        {
                            xw.WriteElementString("OversizePackage", "0");
                        }
                    }
                }
            }

            //Package Service Options
            //xw.WriteStartElement("PackageServiceOptions")
            //xw.WriteStartElement("InsuredValue")
            //xw.WriteElementString("CurrencyCode", "USD")
            //xw.WriteElementString("MonetaryValue", Math.Round(pak.DeclaredValue, 2).ToString())
            //xw.WriteEndElement()
            //xw.WriteEndElement()

            xw.WriteEndElement();
            // End Package
            //--------------------------------------------
        }
コード例 #20
0
 public void Remove(IShippable item)
 {
     this.items.Remove(item);
 }
コード例 #21
0
ファイル: FakeImplement.cs プロジェクト: zrysnd/UberEat
 public void AskProviderToDeliverOrderedGoods(IShippable order)
 {
     //throw new NotImplementedException();
 }
コード例 #22
0
        static void Main(string[] args)
        {
            Shipper        s = new Shipper();
            int            BicycleCounter       = 0;
            int            LawnMowerCounter     = 0;
            int            BaseballGloveCounter = 0;
            int            CrackersCounter      = 0;
            int            counter = 0;
            string         ProductType;
            ConsoleKeyInfo Pressed;
            bool           Compute = false;

            IShippable[] Products = new IShippable[4];
            Products[0] = new Bicycles();
            Products[1] = new Lawn_Mowers();
            Products[2] = new Baseball_Gloves();
            Products[3] = new Crackers();


            do
            {
                //Menu
                Console.Clear();
                Console.WriteLine("Choose from the following options:(enter the number...)");
                Console.WriteLine("1. Add a Bicycle to the Shipment");
                Console.WriteLine("2. Add a Lawn Mower to the Shipment");
                Console.WriteLine("3. Add a Baseball Glove to the shipment");
                Console.WriteLine("4. Add Crackers to the shipment");
                Console.WriteLine("5. List Shipment Items");
                Console.WriteLine("6. Compute Shipping Charges");
                Pressed = Console.ReadKey();
                Console.Clear();
                //if statements taking keypresses
                if (Pressed.Key == ConsoleKey.D1)
                {
                    ProductType = Products[0].Product;
                    s.Add(ProductType, counter, BicycleCounter, LawnMowerCounter, CrackersCounter, BaseballGloveCounter);
                    counter        = s.CounterMethod();
                    BicycleCounter = s.BicycleCounterMethod();
                    Console.WriteLine("1 Bicycle has been added");
                    Console.WriteLine("Press any key to return to the menu");
                    Console.ReadKey();
                }
                if (Pressed.Key == ConsoleKey.D2)
                {
                    ProductType = Products[1].Product;
                    s.Add(ProductType, counter, BicycleCounter, LawnMowerCounter, CrackersCounter, BaseballGloveCounter);
                    counter          = s.CounterMethod();
                    LawnMowerCounter = s.LawnMowerCounterMethod();
                    Console.WriteLine("1 Lawn Mower has been added");
                    Console.WriteLine("Press any key to return to the menu");
                    Console.ReadKey();
                }
                if (Pressed.Key == ConsoleKey.D3)
                {
                    ProductType = Products[2].Product;
                    s.Add(ProductType, counter, BicycleCounter, LawnMowerCounter, CrackersCounter, BaseballGloveCounter);
                    counter = s.CounterMethod();
                    BaseballGloveCounter = s.BaseballGloveCounterMethod();
                    Console.WriteLine("1 Baseball Glove has been added");
                    Console.WriteLine("Press any key to return to the menu");
                    Console.ReadKey();
                }
                if (Pressed.Key == ConsoleKey.D4)
                {
                    ProductType = Products[3].Product;
                    s.Add(ProductType, counter, BicycleCounter, LawnMowerCounter, CrackersCounter, BaseballGloveCounter);
                    counter         = s.CounterMethod();
                    CrackersCounter = s.CrackersCounterMethod();
                    Console.WriteLine("1 Crackers has been added");
                    Console.WriteLine("Press any key to return to the menu");
                    Console.ReadKey();
                }
                if (Pressed.Key == ConsoleKey.D5)
                {
                    Console.WriteLine("Shipment manifest:");
                    if (BicycleCounter == 1)
                    {
                        Console.WriteLine(BicycleCounter + " " + Products[0].Product);
                    }
                    else
                    {
                        Console.WriteLine(BicycleCounter + " " + Products[0].Product + "s");
                    }
                    if (LawnMowerCounter == 1)
                    {
                        Console.WriteLine(LawnMowerCounter + " " + Products[1].Product);
                    }
                    else
                    {
                        Console.WriteLine(LawnMowerCounter + " " + Products[1].Product + "s");
                    }

                    if (BaseballGloveCounter == 1)
                    {
                        Console.WriteLine(BaseballGloveCounter + " " + Products[2].Product);
                    }
                    else
                    {
                        Console.WriteLine(BaseballGloveCounter + " " + Products[2].Product + "s");
                    }

                    Console.WriteLine(CrackersCounter + " " + Products[3].Product);//Crackers is always plural...
                    Console.WriteLine("Press any key to continue...");
                    Console.ReadKey();
                }
                if (Pressed.Key == ConsoleKey.D6)
                {
                    //if the user presses 6, then the program will compute
                    Compute = true;
                    break;
                }
            } while (counter != 10);
            do
            {
                if (Compute == true)
                {
                    break;
                }
                Console.Clear();
                Console.WriteLine("you are at your item limit");
                Console.WriteLine("5. List Shipment Items");
                Console.WriteLine("6. Compute Shipping Charges");
                Pressed = Console.ReadKey();
                Console.Clear();
                if (Pressed.Key == ConsoleKey.D5)
                {
                    Console.WriteLine("Shipment manifest:");
                    if (BicycleCounter == 1)
                    {
                        Console.WriteLine(BicycleCounter + " " + Products[0].Product);
                    }
                    else
                    {
                        Console.WriteLine(BicycleCounter + " " + Products[0].Product + "s");
                    }
                    if (LawnMowerCounter == 1)
                    {
                        Console.WriteLine(LawnMowerCounter + " " + Products[1].Product);
                    }
                    else
                    {
                        Console.WriteLine(LawnMowerCounter + " " + Products[1].Product + "s");
                    }

                    if (BaseballGloveCounter == 1)
                    {
                        Console.WriteLine(BaseballGloveCounter + " " + Products[2].Product);
                    }
                    else
                    {
                        Console.WriteLine(BaseballGloveCounter + " " + Products[2].Product + "s");
                    }

                    Console.WriteLine(CrackersCounter + " " + Products[3].Product);//Crackers is always plural...
                    Console.WriteLine("Press any key to continue...");
                    Console.ReadKey();
                }
                if (Pressed.Key == ConsoleKey.D6)
                {
                    break;
                }
                Console.Clear();
            } while (counter == 10);
            decimal TotalCharge = (BicycleCounter * Products[0].ShipCost) + (LawnMowerCounter * Products[1].ShipCost)
                                  + (BaseballGloveCounter * Products[2].ShipCost) + (CrackersCounter * Products[3].ShipCost);

            Console.WriteLine("Total Shipping cost for this order is $" + Math.Round(TotalCharge, 2));
        }
コード例 #23
0
        public List <Shipment> OptimizeSingleGroup(IShipment shipment)
        {
            decimal MAXWEIGHT = 70;

            // Set Max Weight for Ground Services
            if (this.Settings.ServiceCode == (int)ServiceType.FEDEXGROUND ||
                this.Settings.ServiceCode == (int)ServiceType.GROUNDHOMEDELIVERY)
            {
                MAXWEIGHT = 150;
            }


            List <Shipment> result = new List <Shipment>();

            List <IShippable> itemsToSplit = new List <IShippable>();

            foreach (IShippable item in shipment.Items)
            {
                if (IsOversized(item))
                {
                    Shipment s1 = Shipment.CloneAddressesFromInterface(shipment);
                    s1.Items.Add(item.CloneShippable());
                    result.Add(s1);
                }
                else
                {
                    itemsToSplit.Add(item);
                }
            }


            IShippable tempPackage = new Shippable();

            foreach (IShippable pak in itemsToSplit)
            {
                if (MAXWEIGHT - tempPackage.BoxWeight >= pak.BoxWeight)
                {
                    // add to current box
                    tempPackage.BoxWeight            += pak.BoxWeight;
                    tempPackage.QuantityOfItemsInBox += pak.QuantityOfItemsInBox;
                    tempPackage.BoxValue             += pak.BoxValue;
                }
                else
                {
                    // Save the temp package if it has items
                    if (tempPackage.BoxWeight > 0 || tempPackage.QuantityOfItemsInBox > 0)
                    {
                        Shipment s2 = Shipment.CloneAddressesFromInterface(shipment);
                        s2.Items.Add(tempPackage.CloneShippable());
                        result.Add(s2);

                        tempPackage = new Shippable();
                    }

                    // create new box
                    if (pak.BoxWeight > MAXWEIGHT)
                    {
                        //Loop to break up > maxWeight Packages
                        int     currentItemsInBox = pak.QuantityOfItemsInBox;
                        decimal currentWeight     = pak.BoxWeight;

                        while (currentWeight > 0)
                        {
                            if (currentWeight > MAXWEIGHT)
                            {
                                IShippable newP = pak.CloneShippable();
                                newP.BoxWeight = MAXWEIGHT;
                                if (currentItemsInBox > 0)
                                {
                                    currentItemsInBox        -= 1;
                                    newP.QuantityOfItemsInBox = 1;
                                }

                                Shipment s3 = Shipment.CloneAddressesFromInterface(shipment);
                                s3.Items.Add(newP.CloneShippable());
                                result.Add(s3);
                                currentWeight = currentWeight - MAXWEIGHT;
                                if (currentWeight < 0)
                                {
                                    currentWeight = 0;
                                }
                            }
                            else
                            {
                                // Create a new shippable box
                                IShippable newP = pak.CloneShippable();
                                newP.BoxWeight = currentWeight;
                                if (currentItemsInBox > 0)
                                {
                                    newP.QuantityOfItemsInBox = currentItemsInBox;
                                }
                                Shipment s4 = Shipment.CloneAddressesFromInterface(shipment);
                                s4.Items.Add(newP.CloneShippable());
                                result.Add(s4);
                                currentWeight = 0;
                            }
                        }
                    }
                    else
                    {
                        tempPackage = pak.CloneShippable();
                    }
                }
            }

            // Save the temp package if it has items
            if (tempPackage.BoxWeight > 0 || tempPackage.QuantityOfItemsInBox > 0)
            {
                Shipment s5 = Shipment.CloneAddressesFromInterface(shipment);
                s5.Items.Add(tempPackage.CloneShippable());
                result.Add(s5);

                tempPackage = new Shippable();
            }

            return(result);
        }
コード例 #24
0
 private bool IsOversized(IShippable prod)
 {
     decimal girth = (decimal)(prod.BoxLength + (2m * prod.BoxHeight) + (2m * prod.BoxWidth));
     if (GirthCheck)
     {
         if (girth > GirthMaxInInches) return true;
     }
     if (LengthPlusGirthCheck)
     {
         if ((girth + prod.BoxLength) > LengthPlusGirthMaxInInches) return true;
     }            
     return false;
 }
コード例 #25
0
        public List <IShippable> OptimizePackagesToMaxWeight(IShipment shipment)
        {
            List <IShippable> result       = new List <IShippable>();
            List <IShippable> itemsToSplit = new List <IShippable>();

            // drop off oversize items right away
            foreach (IShippable item in shipment.Items)
            {
                if (IsOversized(item))
                {
                    result.Add(item.CloneShippable());
                }
                else
                {
                    itemsToSplit.Add(item);
                }
            }


            IShippable tempPackage = new Shippable();

            foreach (IShippable pak in itemsToSplit)
            {
                if (_MaxWeight - tempPackage.BoxWeight >= pak.BoxWeight)
                {
                    // add to current box
                    tempPackage.BoxWeight            += pak.BoxWeight;
                    tempPackage.QuantityOfItemsInBox += pak.QuantityOfItemsInBox;
                    tempPackage.BoxValue             += pak.BoxValue;
                }
                else
                {
                    // Save the temp package if it has items
                    if (tempPackage.BoxWeight > 0 || tempPackage.QuantityOfItemsInBox > 0)
                    {
                        result.Add(tempPackage.CloneShippable());
                        tempPackage = new Shippable();
                    }

                    // create new box
                    if (pak.BoxWeight > _MaxWeight)
                    {
                        //Loop to break up > maxWeight Packages
                        int     currentItemsInBox = pak.QuantityOfItemsInBox;
                        decimal currentWeight     = pak.BoxWeight;

                        while (currentWeight > 0)
                        {
                            if (currentWeight > _MaxWeight)
                            {
                                IShippable newP = pak.CloneShippable();
                                newP.BoxWeight = _MaxWeight;
                                if (currentItemsInBox > 0)
                                {
                                    currentItemsInBox        -= 1;
                                    newP.QuantityOfItemsInBox = 1;
                                }
                                result.Add(newP);
                                currentWeight = currentWeight - _MaxWeight;
                                if (currentWeight < 0)
                                {
                                    currentWeight = 0;
                                }
                            }
                            else
                            {
                                // Create a new shippable box
                                IShippable newP = pak.CloneShippable();
                                newP.BoxWeight = currentWeight;
                                if (currentItemsInBox > 0)
                                {
                                    newP.QuantityOfItemsInBox = currentItemsInBox;
                                }
                                result.Add(newP);
                                currentWeight = 0;
                            }
                        }
                    }
                    else
                    {
                        tempPackage = pak.CloneShippable();
                    }
                }
            }

            // Save the temp package if it has items
            if (tempPackage.BoxWeight > 0 || tempPackage.QuantityOfItemsInBox > 0)
            {
                result.Add(tempPackage.CloneShippable());
                tempPackage = new Shippable();
            }

            return(result);
        }
コード例 #26
0
 public void CalculateFreightCosts(IShippable box)
 {
 }