diff --git a/Tank/Tank/Generics/SetGeneric.cs b/Tank/Tank/Generics/SetGeneric.cs index 5126c3c..dd9e778 100644 --- a/Tank/Tank/Generics/SetGeneric.cs +++ b/Tank/Tank/Generics/SetGeneric.cs @@ -40,8 +40,8 @@ namespace Tank.Generics public bool Remove(int position) { - if (position < 0 || position > _maxCount) - return false; + if (position < 0 || position > _maxCount || position >= Count) + throw new TankNotFoundException(position); _places.RemoveAt(position); return true; } @@ -49,15 +49,13 @@ namespace Tank.Generics { get { - if (position < 0 || position > _maxCount) - { + if(position < 0 || position >= Count) return null; - } return _places[position]; } set { - if (position < 0 || position > _maxCount) + if (position < 0 || position > _maxCount || Count == _maxCount) { return; }