diff --git a/ElectricLocomotive/Generics/LocomotivesGenericCollection.cs b/ElectricLocomotive/Generics/LocomotivesGenericCollection.cs
index 7e21c74..182f1f0 100644
--- a/ElectricLocomotive/Generics/LocomotivesGenericCollection.cs
+++ b/ElectricLocomotive/Generics/LocomotivesGenericCollection.cs
@@ -56,14 +56,17 @@ namespace ProjectElectricLocomotive.Generics
///
///
///
- public static bool operator +(LocomotivesGenericCollection collect, T?
- obj)
+ public static int operator +(LocomotivesGenericCollection collect, T? obj)
{
if (obj == null)
{
- return false;
+ return 0;
}
- return collect?._collection.Insert(obj) ?? false;
+ if (collect?._collection.Insert(obj) ?? false)
+ {
+ return collect._collection.Count;
+ }
+ return 0;
}
///
/// Перегрузка оператора вычитания
@@ -71,15 +74,15 @@ namespace ProjectElectricLocomotive.Generics
///
///
///
- public static T? operator -(LocomotivesGenericCollection collect, int
+ public static int operator -(LocomotivesGenericCollection collect, int
pos)
{
T? obj = collect._collection.Get(pos);
- if (obj != null)
+ if (obj != null && collect._collection.Remove(pos))
{
- collect._collection.Remove(pos);
+ return collect._collection.Count;
}
- return obj;
+ return -1;
}
///
/// Получение объекта IMoveableObject
diff --git a/ElectricLocomotive/LogicFormLocomotiveCollection.cs b/ElectricLocomotive/LogicFormLocomotiveCollection.cs
index ca624f5..065adab 100644
--- a/ElectricLocomotive/LogicFormLocomotiveCollection.cs
+++ b/ElectricLocomotive/LogicFormLocomotiveCollection.cs
@@ -41,7 +41,7 @@ namespace ProjectElectricLocomotive
FormLocomotive form = new();
if (form.ShowDialog() == DialogResult.OK)
{
- if (_locomotives + form.SelectedLocomotive)
+ if (_locomotives + form.SelectedLocomotive > 0)
{
MessageBox.Show("Объект добавлен");
pictureBoxCollection.Image = _locomotives.ShowLocomotives();
@@ -66,7 +66,7 @@ namespace ProjectElectricLocomotive
return;
}
int pos = Convert.ToInt32(maskedTextBoxNumber.Text);
- if (_locomotives - pos != null)
+ if (_locomotives - pos != -1)
{
MessageBox.Show("Объект удален");
pictureBoxCollection.Image = _locomotives.ShowLocomotives();