This commit is contained in:
MaxKarme 2022-11-25 16:04:36 +03:00
parent d43966d9eb
commit 7e4fd641e7

View File

@ -30,13 +30,13 @@ namespace AirFighter
public int Insert(T car)
{
// TODO вставка в начало набора
if (_places.Count == _maxCount) return -1;
if (_places.Count == _maxCount) throw new StorageOverflowException(_maxCount);
_places.Insert(0, car);
return 0;
}
public int Insert(T car, int position)
{
if (_places.Count == _maxCount) throw new StorageOverflowException(_maxCount); ;
if (_places.Count == _maxCount) throw new StorageOverflowException(_maxCount);
_places.Insert(position, car);
return position;
}
@ -47,7 +47,7 @@ namespace AirFighter
/// <returns></returns>
public T Remove(int position)
{
if(position >= _maxCount) throw new AircraftNotFoundException(position);
if(position >= _maxCount || position >= _places.Count) throw new AircraftNotFoundException(position);
T res = _places[position];
_places.Remove(res);