From 7e4fd641e7e6cf698604082e72ee2a7dd4cfd297 Mon Sep 17 00:00:00 2001 From: MaxKarme <91691525+MaxKarme@users.noreply.github.com> Date: Fri, 25 Nov 2022 16:04:36 +0300 Subject: [PATCH] fix bugs --- AirFighter/AirFighter/SetCarsGeneric.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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);