diff --git a/Airbus/Airbus/MapsCollection.cs b/Airbus/Airbus/MapsCollection.cs index 8d3cf91..2c3f85a 100644 --- a/Airbus/Airbus/MapsCollection.cs +++ b/Airbus/Airbus/MapsCollection.cs @@ -78,7 +78,7 @@ namespace Airbus { if (!File.Exists(filename)) { - throw new Exception("Файл не найден"); + throw new FileNotFoundException("Файл не найден"); } using (StreamReader sr = new(filename)) @@ -88,7 +88,7 @@ namespace Airbus //если не содержит такую запись или пустой файл if ((str = sr.ReadLine()) == null || !str.Contains("MapsCollection")) { - throw new Exception("Формат данных в файле неправильный"); + throw new FileFormatException("Формат данных в файле неправильный"); } _mapStorage.Clear(); diff --git a/Airbus/Airbus/PlaneNotFoundException.cs b/Airbus/Airbus/PlaneNotFoundException.cs index 8b90594..e48a609 100644 --- a/Airbus/Airbus/PlaneNotFoundException.cs +++ b/Airbus/Airbus/PlaneNotFoundException.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; diff --git a/Airbus/Airbus/SetPlanesGeneric.cs b/Airbus/Airbus/SetPlanesGeneric.cs index b75ddf8..4ef839c 100644 --- a/Airbus/Airbus/SetPlanesGeneric.cs +++ b/Airbus/Airbus/SetPlanesGeneric.cs @@ -36,10 +36,19 @@ 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; diff --git a/Airbus/Airbus/StorageOverflowException.cs b/Airbus/Airbus/StorageOverflowException.cs index 7ddeb57..3a95d3c 100644 --- a/Airbus/Airbus/StorageOverflowException.cs +++ b/Airbus/Airbus/StorageOverflowException.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks;