From 4de1bca002ed2108e880cf319f2b8e9c4caafa6f Mon Sep 17 00:00:00 2001 From: sqdselo <147947144+sqdselo@users.noreply.github.com> Date: Mon, 22 Apr 2024 19:48:41 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9B=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=BD=D0=B0=D1=8F=203=20=D1=84=D0=B8=D0=BD=D0=B0?= =?UTF-8?q?=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AbstractCompany.cs | 2 +- .../CollectionGenericObjects/Garage.cs | 3 +- .../MassivGenericObjects.cs | 46 +++++++++---------- 3 files changed, 26 insertions(+), 25 deletions(-) diff --git a/HoistingCrane/HoistingCrane/CollectionGenericObjects/AbstractCompany.cs b/HoistingCrane/HoistingCrane/CollectionGenericObjects/AbstractCompany.cs index 5d05d6f..7b4bc7a 100644 --- a/HoistingCrane/HoistingCrane/CollectionGenericObjects/AbstractCompany.cs +++ b/HoistingCrane/HoistingCrane/CollectionGenericObjects/AbstractCompany.cs @@ -30,7 +30,7 @@ namespace HoistingCrane.CollectionGenericObjects { get { - return (pictureWidth * pictureHeight) / (_placeSizeHeight * _placeSizeWidth); + return (pictureWidth * pictureHeight) / (_placeSizeHeight * _placeSizeWidth)-3; } } public AbstractCompany(int picWidth, int picHeight, ICollectionGenericObjects array) diff --git a/HoistingCrane/HoistingCrane/CollectionGenericObjects/Garage.cs b/HoistingCrane/HoistingCrane/CollectionGenericObjects/Garage.cs index 3aedcb2..0839cb8 100644 --- a/HoistingCrane/HoistingCrane/CollectionGenericObjects/Garage.cs +++ b/HoistingCrane/HoistingCrane/CollectionGenericObjects/Garage.cs @@ -36,7 +36,7 @@ namespace HoistingCrane.CollectionGenericObjects arr?.Get(i)?.SetPictureSize(pictureWidth, pictureHeight); arr?.Get(i)?.SetPosition(_placeSizeWidth * currentPosWidth + 25, _placeSizeHeight * currentPosHeight + 15); } - + if (currentPosWidth > 0) currentPosWidth--; else @@ -51,5 +51,6 @@ namespace HoistingCrane.CollectionGenericObjects } } + } } diff --git a/HoistingCrane/HoistingCrane/CollectionGenericObjects/MassivGenericObjects.cs b/HoistingCrane/HoistingCrane/CollectionGenericObjects/MassivGenericObjects.cs index 2573492..3e2d561 100644 --- a/HoistingCrane/HoistingCrane/CollectionGenericObjects/MassivGenericObjects.cs +++ b/HoistingCrane/HoistingCrane/CollectionGenericObjects/MassivGenericObjects.cs @@ -31,50 +31,50 @@ } public int Insert(T obj) { - for (int i = 0; i < Count; i++) - { - if (arr[i] == null) - { - return Insert(obj, 0); - } - } - return -1; + return Insert(obj, 0); } public int Insert(T obj, int position) { - //todo Проверка позиции + if (position < 0 || position > Count) { return -1; } - if (arr[position] == null) + int pos = position - 1; + + while (position < Count) { - arr[position] = obj; - return position; - } - else - { - if (Insert(obj, position + 1) != null) + if (arr[position] == null) { + arr[position] = obj; return position; } - if (Insert(obj, position - 1) != null) + position++; + } + while (pos > 0) + { + if (arr[position] == null) { + arr[position] = obj; return position; } + position--; } + return -1; - } + + } public T? Remove(int position) { - if(position >= 0 && position < Count) + if (position < 0 || position > Count) { - T? temp = arr[position]; - arr[position] = null; - return temp; + return null; } - return null; + + T? removed_object = arr[position]; + arr[position] = null; + return removed_object; } } }