lab8 some minor fixes

This commit is contained in:
Zakharov_Rostislav 2023-12-21 20:46:41 +04:00
parent 179681f849
commit d3abdb424d

View File

@ -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<T?> comparer) => _places.Sort(comparer);
public void Remove(int position)