diff --git a/AirFighter/AirFighter/SetCarsGeneric.cs b/AirFighter/AirFighter/SetCarsGeneric.cs index e1331b2..72f1d1d 100644 --- a/AirFighter/AirFighter/SetCarsGeneric.cs +++ b/AirFighter/AirFighter/SetCarsGeneric.cs @@ -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 /// 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);