private DoubleLinkedList <DataTimeForXY> .Node AddNodeToTimeQueue(double x, double y)
        {
            DataTimeForXY newBox = new DataTimeForXY(x, y);

            boxTimeQueue.AddLast(newBox);
            return(boxTimeQueue.end);
        }
Example #2
0
        public override bool Equals(object obj)
        {
            if ((obj == null) || !this.GetType().Equals(obj.GetType()))
            {
                return(false);
            }
            DataTimeForXY found = (DataTimeForXY)obj;

            return((x == found.x) && (y == found.y));
        }
 //adding to end boxTimeQueue
 public void AddBox(double x, double y, int amount)
 {
     if (x > 0 && y > 0 && amount > 0)
     {
         searchX = new DataSideX(x);
         searchY = new DataSideY(y, amount);
         if (mainTree.Search(searchX, out foundX))
         {
             if (foundX.tree.Search(searchY, out foundY))
             {
                 if (foundY.quantity == DataSideY.maxCount)
                 {
                     myShowMessage($"Stock of this boxes is full, we cant add more. {amount} boxes we will return to supplier");
                 }
                 else
                 {
                     DataTimeForXY old = new DataTimeForXY(foundX.lengthX, foundY.lengthY);
                     RemoveNodeFromTimeQueue(foundY);
                     foundY.quantity         += amount;
                     foundY.refOfBoxTimeQueue = AddNodeToTimeQueue(foundX.lengthX, foundY.lengthY);
                     if (foundY.quantity > DataSideY.maxCount)
                     {
                         int boxToReturn = foundY.quantity - DataSideY.maxCount;
                         foundY.quantity = DataSideY.maxCount;
                         myShowMessage($"We already have such box in stock, we wanted to add {amount} boxes but we have limit {DataSideY.maxCount} boxes, " +
                                       $"so {boxToReturn} boxes we will return to supplier. Our stock now {DataSideY.maxCount} boxes.");
                     }
                     else
                     {
                         myShowMessage($"We already have such box in stock, we added {amount} to stock.  Our stock now {foundY.quantity} boxes.");
                     }
                 }
             }
             else
             {
                 searchY.refOfBoxTimeQueue = AddNodeToTimeQueue(x, y);
                 if (searchY.quantity > DataSideY.maxCount)
                 {
                     int boxToReturn = searchY.quantity - DataSideY.maxCount;
                     searchY.quantity = DataSideY.maxCount;
                     foundX.tree.Add(searchY);
                     myShowMessage($"We added new box (depth ={foundX.lengthX}, height={foundY.lengthY}) to stock.   But we have limit {DataSideY.maxCount} boxes, so {boxToReturn} boxes we will return to supplier. Now we have in stock {DataSideY.maxCount} such boxes.");
                 }
                 else
                 {
                     foundX.tree.Add(searchY);
                     myShowMessage($"We added new box (depth ={foundX.lengthX}, height={searchY.lengthY}) to stock. Now we have in stock {searchY.quantity} such boxes.");
                 }
             }
         }
         else
         {
             searchY.refOfBoxTimeQueue = AddNodeToTimeQueue(x, y);
             if (searchY.quantity > DataSideY.maxCount)
             {
                 int boxToReturn = searchY.quantity - DataSideY.maxCount;
                 searchY.quantity = DataSideY.maxCount;
                 searchX.tree.Add(searchY);
                 mainTree.Add(searchX);
                 myShowMessage($"We added new box to stock. But we have limit {DataSideY.maxCount} boxes, so {boxToReturn} boxes we will return to supplier. Now we have in stock { searchY.quantity} such boxes.");
             }
             else
             {
                 searchX.tree.Add(searchY);
                 mainTree.Add(searchX);
                 myShowMessage($"We added new box (depth ={searchX.lengthX}, height={searchY.lengthY}) to stock.  Now we have in stock {searchY.quantity} such boxes.");
             }
         }
     }
 }