diff --git a/Liner/Liner/SetShipsGeneric.cs b/Liner/Liner/SetShipsGeneric.cs index 5c9bfad..6e6c3b5 100644 --- a/Liner/Liner/SetShipsGeneric.cs +++ b/Liner/Liner/SetShipsGeneric.cs @@ -19,21 +19,17 @@ namespace Liner } public int Insert(T ship) { - if (_places.Count > _maxCount) - { - return -1; - } return Insert(ship, 0); } public int Insert(T ship, int position) { - if (position >= _maxCount || position < 0) return -1; + if (position < 0 || position > Count || _maxCount == Count) return -1; _places.Insert(position, ship); return position; } public T Remove(int position) { - if (position >= _maxCount || position < 0) + if (position >= Count || position < 0) { return null; } @@ -45,7 +41,7 @@ namespace Liner { get { - if (position >= _places.Count || position < 0) + if (position >= Count || position < 0) { return null; } @@ -53,7 +49,7 @@ namespace Liner } set { - if (position >= _places.Count || position < 0) + if (position >= Count || position < 0) { return; }