PIbd-21_Rasubaev S.M._Lab7 #7

Closed
Sergey wants to merge 2 commits from lab_7 into lab_6
Showing only changes of commit b45f27b91d - Show all commits

View File

@ -25,6 +25,7 @@ namespace HoistingCrane.Generics
if (Count >= _maxCount)
throw new StorageOverflowException(Count);
_places.Insert(0, crane);
if (_places.Contains(null)) _places.Remove(null);
return 0;
}
public int Insert(T crane, int position)
@ -34,13 +35,15 @@ namespace HoistingCrane.Generics
if (Count >= _maxCount)
throw new StorageOverflowException(Count);
_places.Insert(position, crane);
if(_places.Contains(null)) _places.Remove(null);
return position;
}
/// Удаление объекта из набора с конкретной позиции
public bool Remove(int position)
{
if (_places[position] == null)
if (position < 0 || position > _maxCount || position >= Count || _places[position] == null)
throw new CraneNotFoundException(position);
if ((position < 0) || (position > _maxCount)) return false;
_places[position] = null;
return true;
@ -56,7 +59,9 @@ namespace HoistingCrane.Generics
{
get
{
if (position < 0 || position > _maxCount)
if (position < 0 || position > Count)
return null;
if (_places.Count <= position)
return null;
return _places[position];
}
@ -64,6 +69,8 @@ namespace HoistingCrane.Generics
{
if (position < 0 || position > _maxCount)
return;
if (_places.Count <= position)
return;
_places[position] = value;
}
}