From d3abdb424d1b3a82c925cc2882ee14e814367a4f Mon Sep 17 00:00:00 2001 From: Zakharov_Rostislav Date: Thu, 21 Dec 2023 20:46:41 +0400 Subject: [PATCH] lab8 some minor fixes --- ProjectBattleship/ProjectBattleship/SetGeneric.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ProjectBattleship/ProjectBattleship/SetGeneric.cs b/ProjectBattleship/ProjectBattleship/SetGeneric.cs index 1b6ca07..1e16a07 100644 --- a/ProjectBattleship/ProjectBattleship/SetGeneric.cs +++ b/ProjectBattleship/ProjectBattleship/SetGeneric.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Numerics; using System.Text; using System.Threading.Tasks; @@ -28,14 +29,14 @@ namespace ProjectBattleship.Generics { if (_places.Count == _maxCount) throw new StorageOverflowException(_maxCount); - if (!(position >= 0 && position < Count)) - throw new Exception("Неверная позиция для вставки"); + if (!(position >= 0 && position <= Count)) + throw new Exception($"Неверная позиция для вставки"); if (equal != null) { if (_places.Contains(ship, equal)) throw new ArgumentException(nameof(ship)); } - _places[position] = ship; + _places.Insert(position, ship); } public void SortSet(IComparer comparer) => _places.Sort(comparer); public void Remove(int position)