Example #1
0
 public void AddShelf(Shelf shelf)
 {
     if (isOpen)
     {
         if (fridgeSize.Equals(shelf.ShelfSize))
         {
             if (shelfContainer[shelf.ID - 1] == null)
             {
                 if (shelfContainer[shelf.ID].NotContainsBigItem())
                 {
                     shelfContainer[shelf.ID - 1] = shelf;
                 }
                 else
                 {
                     throw new BigItemCoolingException();
                 }
             }
             else
             {
                 throw new SizeNotCompatableException();
             }
         }
         else
         {
             throw new SizeNotCompatableException();
         }
     }
     else
     {
         throw new FridgeIsClosedException();
     }
 }
Example #2
0
 public void AddFood(Food food)
 {
     if (isOpen)
     {
         if (food._size < CheckMaxShelfCapacity())
         {
             var isFull = true;
             if (food.Size < 20)
             {
                 isFull = CoolSmallItem(food);
             }
             else if (food.Size > 80)
             {
                 RemovedShelf = CoolBigItem(food);
                 isFull       = false;
             }
             else
             {
                 foreach (var shelf in shelfContainer)
                 {
                     if (shelf != null)
                     {
                         if (shelf.AddFood(food))
                         {
                             isFull = false;
                             break;
                         }
                     }
                 }
             }
             if (isFull)
             {
                 throw new FridgeIsFullException();
             }
         }
         else
         {
             throw new BigItemCoolingException();
         }
     }
     else
     {
         throw new FridgeIsClosedException();
     }
 }