From 2d1622a1b6f032bc1cd25c8180343111ad57246e Mon Sep 17 00:00:00 2001 From: Pavel_Sorokin Date: Wed, 26 Oct 2022 15:21:35 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=B1=D1=80=D0=B0=D0=BD=D1=8B=20=D0=BB?= =?UTF-8?q?=D0=B8=D1=88=D0=BD=D0=B8=D0=B5=20=D1=81=D1=82=D1=80=D0=BE=D1=87?= =?UTF-8?q?=D0=BA=D0=B8.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Liner/Liner/SetShipsGeneric.cs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) 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; }