From feea0da22be55bb54a0ca29fccbda546e62f703a Mon Sep 17 00:00:00 2001
From: sqdselo <147947144+sqdselo@users.noreply.github.com>
Date: Thu, 4 Apr 2024 14:53:50 +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=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82?=
=?UTF-8?q?a=203?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../CollectionGenericObjects/AbstractCompany.cs | 4 ++--
.../ICollectionGenericObjects.cs | 4 ++--
.../MassivGenericObjects.cs | 16 ++++++++--------
HoistingCrane/HoistingCrane/FormCarCollection.cs | 2 +-
4 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/HoistingCrane/HoistingCrane/CollectionGenericObjects/AbstractCompany.cs b/HoistingCrane/HoistingCrane/CollectionGenericObjects/AbstractCompany.cs
index 45ca30e..5d05d6f 100644
--- a/HoistingCrane/HoistingCrane/CollectionGenericObjects/AbstractCompany.cs
+++ b/HoistingCrane/HoistingCrane/CollectionGenericObjects/AbstractCompany.cs
@@ -41,9 +41,9 @@ namespace HoistingCrane.CollectionGenericObjects
arr.SetMaxCount = GetMaxCount;
}
- public static DrawningTrackedVehicle operator +(AbstractCompany company, DrawningTrackedVehicle car)
+ public static int operator +(AbstractCompany company, DrawningTrackedVehicle car)
{
- return company.arr?.Insert(car) ?? null;
+ return company.arr?.Insert(car) ?? -1;
}
public static DrawningTrackedVehicle operator -(AbstractCompany company, int position)
{
diff --git a/HoistingCrane/HoistingCrane/CollectionGenericObjects/ICollectionGenericObjects.cs b/HoistingCrane/HoistingCrane/CollectionGenericObjects/ICollectionGenericObjects.cs
index ce4dbb0..2ca324a 100644
--- a/HoistingCrane/HoistingCrane/CollectionGenericObjects/ICollectionGenericObjects.cs
+++ b/HoistingCrane/HoistingCrane/CollectionGenericObjects/ICollectionGenericObjects.cs
@@ -16,14 +16,14 @@
///
///
///
- T? Insert(T obj);
+ int Insert(T obj);
///
/// Добавление элемента в коллекцию на определенную позицию
///
///
///
///
- T? Insert(T obj, int position);
+ int Insert(T obj, int position);
///
/// Удаление элемента из коллекции по его позиции
///
diff --git a/HoistingCrane/HoistingCrane/CollectionGenericObjects/MassivGenericObjects.cs b/HoistingCrane/HoistingCrane/CollectionGenericObjects/MassivGenericObjects.cs
index 0fcf4a2..64e8e12 100644
--- a/HoistingCrane/HoistingCrane/CollectionGenericObjects/MassivGenericObjects.cs
+++ b/HoistingCrane/HoistingCrane/CollectionGenericObjects/MassivGenericObjects.cs
@@ -30,7 +30,7 @@
return null;
}
- public T? Insert(T obj)
+ public int Insert(T obj)
{
for (int i = 0; i < Count; i++)
{
@@ -39,34 +39,34 @@
return Insert(obj, 0);
}
}
- return null;
+ return -1;
}
- public T? Insert(T obj, int position)
+ public int Insert(T obj, int position)
{
//todo Проверка позиции
if (position < 0 || position > Count)
{
- return null;
+ return -1;
}
if (arr[position] == null)
{
arr[position] = obj;
- return arr[position];
+ return position;
}
else
{
if (Insert(obj, position + 1) != null)
{
- return arr[position + 1];
+ return position;
}
if (Insert(obj, position - 1) != null)
{
- return arr[position - 1];
+ return position;
}
}
- return null;
+ return -1;
}
public T? Remove(int position)
diff --git a/HoistingCrane/HoistingCrane/FormCarCollection.cs b/HoistingCrane/HoistingCrane/FormCarCollection.cs
index fb77e28..8854ea1 100644
--- a/HoistingCrane/HoistingCrane/FormCarCollection.cs
+++ b/HoistingCrane/HoistingCrane/FormCarCollection.cs
@@ -38,7 +38,7 @@ namespace HoistingCrane
default:
return;
}
- if ((_company + drawning) != null)
+ if ((_company + drawning) != -1)
{
MessageBox.Show("Объект добавлен");
pictureBox.Image = _company.Show();