исправления 7 лабораторной

This commit is contained in:
sardq 2023-12-28 09:44:41 +04:00
parent 0e7878555f
commit b45f27b91d

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;
}
}