diff --git a/Airbus/Airbus/Airbus.csproj b/Airbus/Airbus/Airbus.csproj index a5bf5b2..6a62cf2 100644 --- a/Airbus/Airbus/Airbus.csproj +++ b/Airbus/Airbus/Airbus.csproj @@ -26,7 +26,6 @@ - diff --git a/Airbus/Airbus/MapsCollection.cs b/Airbus/Airbus/MapsCollection.cs index 0455f09..fca15ee 100644 --- a/Airbus/Airbus/MapsCollection.cs +++ b/Airbus/Airbus/MapsCollection.cs @@ -79,7 +79,7 @@ namespace Airbus { if (!File.Exists(filename)) { - throw new Exception("Файл не найден"); + throw new FileNotFoundException("Файл не найден"); } using (StreamReader sr = new(filename)) @@ -89,7 +89,7 @@ namespace Airbus //если не содержит такую запись или пустой файл if ((str = sr.ReadLine()) == null || !str.Contains("MapsCollection")) { - throw new Exception("Формат данных в файле неправильный"); + throw new FileFormatException("Формат данных в файле неправильный"); } _mapStorage.Clear(); diff --git a/Airbus/Airbus/SetPlanesGeneric.cs b/Airbus/Airbus/SetPlanesGeneric.cs index ec1063b..bdebdd9 100644 --- a/Airbus/Airbus/SetPlanesGeneric.cs +++ b/Airbus/Airbus/SetPlanesGeneric.cs @@ -36,11 +36,21 @@ namespace Airbus //добавление объекта в набор на конкретную позицию public int Insert(T plane, int position) { - if (position >= _maxCount && position < 0) + if (position > _maxCount && position < 0) { return -1; } + if (_places.Contains(plane)) + { + throw new ArgumentException($"Объект {plane} уже есть в наборе"); + } + + if(Count == _maxCount) + { + throw new StorageOverflowException(_maxCount); + } + _places.Insert(position, plane); return position;