diff --git a/SelfPropelledArtilleryUnit/SetArtilleriesGeneric.cs b/SelfPropelledArtilleryUnit/SetArtilleriesGeneric.cs index 1f60477..eeab600 100644 --- a/SelfPropelledArtilleryUnit/SetArtilleriesGeneric.cs +++ b/SelfPropelledArtilleryUnit/SetArtilleriesGeneric.cs @@ -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; }