From 38ed0c2a42a47169fa61d0d09d60f12b8c67ebf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B5=D0=BB=D1=8C=D0=BD=D0=B8=D0=BA=D0=BE=D0=B2=20?= =?UTF-8?q?=D0=98=D0=B3=D0=BE=D1=80=D1=8C?= Date: Thu, 13 Oct 2022 15:09:19 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9B=D0=B0=D0=B1=203?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Locomotives/Locomotives/SetLocomotivesGeneric.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Locomotives/Locomotives/SetLocomotivesGeneric.cs b/Locomotives/Locomotives/SetLocomotivesGeneric.cs index 08f13cc..4acfef9 100644 --- a/Locomotives/Locomotives/SetLocomotivesGeneric.cs +++ b/Locomotives/Locomotives/SetLocomotivesGeneric.cs @@ -27,6 +27,18 @@ public bool Insert(T locomotive) { // TODO проверка на наличие свободных мест + T testLocomotive = _places[0]; + for (int i = 0; i < Count; i++) + { + if (_places[i] == null) + { + testLocomotive = _places[i]; + } + } + if (testLocomotive != null) + { + return false; + } for (int i = Count - 2; i >= 0; i--) { _places[i + 1] = _places[i];