diff --git a/AccordionBus/AccordionBus/CollectionGenericObjects/AbstractCompany.cs b/AccordionBus/AccordionBus/CollectionGenericObjects/AbstractCompany.cs
index 23479f1..2a77699 100644
--- a/AccordionBus/AccordionBus/CollectionGenericObjects/AbstractCompany.cs
+++ b/AccordionBus/AccordionBus/CollectionGenericObjects/AbstractCompany.cs
@@ -29,14 +29,14 @@ namespace AccordionBus.CollectionGenericObjects
_collection.SetMaxCount = GetMaxCount;
}
- public static bool operator +(AbstractCompany company, DrawningBus bus)
+ public static int operator +(AbstractCompany company, DrawningBus bus)
{
- return company._collection?.Insert(bus) ?? false;
+ return company._collection.Insert(bus);
}
- public static bool operator -(AbstractCompany company, int position)
+ public static DrawningBus? operator -(AbstractCompany company, int position)
{
- return company._collection?.Remove(position) ?? false;
+ return company._collection.Remove(position);
}
public DrawningBus? GetRandomObject()
diff --git a/AccordionBus/AccordionBus/CollectionGenericObjects/ICollectionGenericObjects.cs b/AccordionBus/AccordionBus/CollectionGenericObjects/ICollectionGenericObjects.cs
index 10b3762..bf04efc 100644
--- a/AccordionBus/AccordionBus/CollectionGenericObjects/ICollectionGenericObjects.cs
+++ b/AccordionBus/AccordionBus/CollectionGenericObjects/ICollectionGenericObjects.cs
@@ -22,20 +22,20 @@ namespace AccordionBus.CollectionGenericObjects
///
/// добавляемый объект
///
- bool Insert(T obj);
+ int Insert(T obj);
///
/// вставить по позиции
///
/// добавляемый объект
/// индекс
///
- bool Insert(T obj, int position);
+ int Insert(T obj, int position);
///
/// удаление
///
/// индекс
///
- bool Remove(int position);
+ T? Remove(int position);
///
/// получение объекта по позиции
///
diff --git a/AccordionBus/AccordionBus/CollectionGenericObjects/MassiveGenericObjects.cs b/AccordionBus/AccordionBus/CollectionGenericObjects/MassiveGenericObjects.cs
index 4caf5c1..0489942 100644
--- a/AccordionBus/AccordionBus/CollectionGenericObjects/MassiveGenericObjects.cs
+++ b/AccordionBus/AccordionBus/CollectionGenericObjects/MassiveGenericObjects.cs
@@ -26,27 +26,27 @@ namespace AccordionBus.CollectionGenericObjects
return _collection[position];
}
- public bool Insert(T obj)
+ public int Insert(T obj)
{
for (int i = 0; i < _collection.Length; i++)
{
if (_collection[i] == null)
{
_collection[i] = obj;
- return true;
+ return i;
}
}
- return false;
+ return -1;
}
- public bool Insert(T obj, int position)
+ public int Insert(T obj, int position)
{
- if (position < 0 || position >= _collection.Length) { return false; }
+ if (position < 0 || position >= _collection.Length) { return -1; }
if (_collection[position] == null)
{
_collection[position] = obj;
- return true;
+ return position;
}
else
{
@@ -55,7 +55,7 @@ namespace AccordionBus.CollectionGenericObjects
if (_collection[i] == null)
{
_collection[i] = obj;
- return true;
+ return i;
}
}
@@ -64,19 +64,20 @@ namespace AccordionBus.CollectionGenericObjects
if (_collection[i] == null)
{
_collection[i] = obj;
- return true;
+ return i;
}
}
}
- return false;
+ return -1;
}
- public bool Remove(int position)
+ public T? Remove(int position)
{
- if (position < 0 || position >= _collection.Length) { return false;}
+ if (position < 0 || position >= _collection.Length) { return null;}
+ T? obj = _collection[position];
_collection[position] = null;
- return true;
+ return obj;
}
}
}
diff --git a/AccordionBus/AccordionBus/FormBusCollection.cs b/AccordionBus/AccordionBus/FormBusCollection.cs
index 4873e21..d9fb03a 100644
--- a/AccordionBus/AccordionBus/FormBusCollection.cs
+++ b/AccordionBus/AccordionBus/FormBusCollection.cs
@@ -55,7 +55,7 @@ namespace AccordionBus
return;
}
- if (_company + _drawningBus)
+ if (_company + _drawningBus != -1)
{
MessageBox.Show("Объект добавлен");
pictureBox.Image = _company.Show();
@@ -89,7 +89,7 @@ namespace AccordionBus
if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) return;
int pos = Convert.ToInt32(maskedTextBox.Text);
- if (_company - pos)
+ if (_company - pos is DrawningBus)
{
MessageBox.Show("Объект удалён");
pictureBox.Image = _company.Show();