예제 #1
0
 public I3DStorageObject StoreAtFreeLocation(I3DStorageObject product)//calling this method if user didnt say where it wanted to store the object
 {
     for (int i = startindex; i < slots.GetLength(0); i++)
     {
         for (int j = startindex; j < slots.GetLength(1);)
         {
             if (slots[i, j] != null)
             {
                 result = slots[i, j].StoreProduct(product, product.Weight, product.Volume, product.IsFragile, product.MaxDimension);
                 if (!result)
                 {
                     j++;
                 }
                 else
                 {
                     return(slots[i, j].FoundByID(product.ID));
                 }
             }
             else if (slots[i, j] == null)
             {
                 slots[i, j] = new WareHouseLocation(i, j);
                 slots[i, j].StoreProduct(product, product.Weight, product.Volume, product.IsFragile, product.MaxDimension);
                 return(slots[i, j].FoundByID(product.ID));
             }
         }
     }
     return(null);
 }
예제 #2
0
 public I3DStorageObject StoreAtIndexLocation(int slot, int floor, I3DStorageObject product, int oldFloorPosition, int oldBoxPosition)
 {
     if (slots[floor, slot] == null)
     {
         if (oldFloorPosition > 0 && oldBoxPosition > 0)
         {
             slots[oldFloorPosition, oldBoxPosition].RemoveProduct(product.ID, product.Weight, product.Volume);
             if (slots[oldFloorPosition, oldBoxPosition].ProductCount == 0)
             {
                 slots[oldFloorPosition, oldBoxPosition] = null;
             }
         }
         slots[floor, slot] = new WareHouseLocation(floor, slot);
         slots[floor, slot].StoreProduct(product, product.Weight, product.Volume, product.IsFragile, product.MaxDimension);
         return(slots[floor, slot].FoundByID(product.ID));
     }
     if (slots[floor, slot] != null)
     {
         result = slots[floor, slot].StoreProduct(product, product.Weight, product.Volume, product.IsFragile, product.MaxDimension);
         if (result)
         {
             if (oldFloorPosition > 0 && oldBoxPosition > 0)
             {
                 slots[oldFloorPosition, oldBoxPosition].RemoveProduct(product.ID, product.Weight, product.Volume);
                 if (slots[oldFloorPosition, oldBoxPosition].ProductCount == 0)
                 {
                     slots[oldFloorPosition, oldBoxPosition] = null;
                 }
             }
             //slots[floor, slot].StoreProduct(product, product.Weight, product.Volume, product.IsFragile, product.MaxDimension);
         }
         else
         {   //removes the product from its old position
             throw new ArgumentException($"Level {floor} at box positon {slot} is full"
                                         + $" the product could not be added\n");
             //adds the product to the new positon / "moves it to the new position box"
         }
         return(slots[floor, slot].FoundByID(product.ID));
     }
     return(null);
 }