Добавлено выбрасывание исключений в SetArtilleriesGeneric

This commit is contained in:
Сергей Полевой 2022-11-08 00:42:14 +04:00
parent 74dfc308ca
commit eb4416e7ed

View File

@ -26,7 +26,12 @@ namespace Artilleries
public int Insert(T artillery, int position)
{
if (position < 0 || position > Count || Count == _maxCount)
if (Count == _maxCount)
{
throw new StorageOverflowException(_maxCount);
}
if (position < 0 || position > Count)
{
return -1;
}
@ -45,6 +50,11 @@ namespace Artilleries
var result = _places[position];
if (result == null)
{
throw new ArtilleryNotFoundException(position);
}
_places.RemoveAt(position);
return result;
}