Exemplo n.º 1
0
        static void AddBox(string boxType)
        {
            I3DStorageObject box = null;
            int    id            = GetId(true);
            string description   = GetDescription();
            double weight        = GetWeight();
            bool   isFragile     = GetFragile();

            try
            {
                switch (boxType)
                {
                case "cube":
                    int side = GetSide(string.Empty);
                    box = _wareHouse.CreateCube(id, description, weight, isFragile, side);
                    break;

                case "cubeoid":
                    int xSide = GetSide("x");
                    int ySide = GetSide("y");
                    int zSide = GetSide("z");
                    box = _wareHouse.CreateCubeoid(id, description, weight, isFragile, xSide, ySide, zSide);
                    break;

                case "sphere":
                    int radius = GetRadius();
                    box = _wareHouse.CreateSphere(id, description, weight, isFragile, radius);
                    break;

                case "blob":
                    side = GetSide("");
                    box  = _wareHouse.CreateBlob(id, description, weight, side);
                    break;
                }
                int pos = -1;

                if (ManualPos())
                {
                    pos = GetManualLocation();
                }
                else
                {
                    pos = GetAutomaticLocation(box);
                }

                _wareHouse.StoreBox(box, pos);
                Console.WriteLine("The box was added succesfully");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.ReadLine();
            }
        }