Ejemplo n.º 1
0
        public int Add(BoxSpecs box, int level = 0, int location = 0)
        {
            I3DObject shape = CreateBox(box);

            if (level > 0 && location > 0)
            {
                bool succesfullAdd = facility[level, location].TryAdd(shape);
                if (succesfullAdd)
                {
                    return(shape.Id);
                }
                return(-1);
            }

            for (int levels = 1; level < facility.GetLength(0); level++)
            {
                for (int locations = 1; locations < facility.GetLength(1); locations++)
                {
                    if (facility[levels, locations].TryAdd(shape))
                    {
                        return(shape.Id);
                    }
                }
            }
            return(-1);
        }
Ejemplo n.º 2
0
        private I3DObject CreateBox(BoxSpecs box)
        {
            this.Id++;
            I3DObject shape;

            if (box.Description == "CubeOid")
            {
                shape = new CubeOid(box.XLength, box.YLength, box.ZLength, Id, box.Weight, box.Description, box.IsFragile, box.InsuranceValue);
            }
            else if (box.Description == "Blob")
            {
                shape = new Blob(box.XLength, Id, box.Weight, box.Description, box.InsuranceValue);
            }
            else if (box.Description == "Cube")
            {
                shape = new Cube(box.XLength, Id, box.Weight, box.Description, box.IsFragile, box.InsuranceValue);
            }
            else
            {
                shape = new Sphere((box.XLength * 2), Id, box.Weight, box.Description, box.IsFragile, box.InsuranceValue);
            }
            return(shape);
        }