diff --git a/AccordionBus/AccordionBus/AbstractMap.cs b/AccordionBus/AccordionBus/AbstractMap.cs index 06068a2..494b6cd 100644 --- a/AccordionBus/AccordionBus/AbstractMap.cs +++ b/AccordionBus/AccordionBus/AbstractMap.cs @@ -165,24 +165,23 @@ namespace AccordionBus { return false; } - var otherMap = other as AbstractMap; - if (otherMap == null) + if (other == null) { return false; } - if (_width != otherMap._width) + if (_width != other._width) { return false; } - if (_height != otherMap._height) + if (_height != other._height) { return false; } - if (_size_x != otherMap._size_x) + if (_size_x != other._size_x) { return false; } - if (_size_y != otherMap._size_y) + if (_size_y != other._size_y) { return false; } @@ -190,7 +189,7 @@ namespace AccordionBus { for (int j = 0; j < _map.GetLength(1); j++) { - if (_map[i, j] != otherMap._map[i, j]) + if (_map[i, j] != other._map[i, j]) { return false; } diff --git a/AccordionBus/AccordionBus/FormMapWithSetBuses.cs b/AccordionBus/AccordionBus/FormMapWithSetBuses.cs index 4025ef7..e83a7dc 100644 --- a/AccordionBus/AccordionBus/FormMapWithSetBuses.cs +++ b/AccordionBus/AccordionBus/FormMapWithSetBuses.cs @@ -157,6 +157,11 @@ namespace AccordionBus _logger.LogWarning($"Ошибка переполнения хранилища: {ex.Message}"); MessageBox.Show($"Ошибка переполнения хранилища: {ex.Message}", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error); } + catch (ArgumentException ex) + { + _logger.LogWarning($"Ошибка добавления: {ex.Message}"); + MessageBox.Show($"Ошибка добавления: {ex.Message}"); + } catch (Exception ex) { _logger.LogWarning($"Неизвестная ошибка: {ex.Message}"); diff --git a/AccordionBus/AccordionBus/SetBusesGeneric.cs b/AccordionBus/AccordionBus/SetBusesGeneric.cs index 5de6f7f..4e9cc11 100644 --- a/AccordionBus/AccordionBus/SetBusesGeneric.cs +++ b/AccordionBus/AccordionBus/SetBusesGeneric.cs @@ -52,7 +52,7 @@ namespace AccordionBus // Проверка на уникальность if (_places.Contains(bus)) { - return -1; + throw new ArgumentException("Объект с такими характеристиками уже существует в наборе."); } //проверка позиции if (Count == _maxCount)