diff --git a/ProjectAircraftCarrier_/ProjectAircraftCarrier_/CollectionGenericObjects/AbstractCompany.cs b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/CollectionGenericObjects/AbstractCompany.cs
index 192350a..4bedf0b 100644
--- a/ProjectAircraftCarrier_/ProjectAircraftCarrier_/CollectionGenericObjects/AbstractCompany.cs
+++ b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/CollectionGenericObjects/AbstractCompany.cs
@@ -57,9 +57,9 @@ public abstract class AbstractCompany
/// Компания
/// Добавляемый объект
///
- public static bool operator +(AbstractCompany company, DrawningWarship warship)
+ public static int operator +(AbstractCompany company, DrawningWarship warship)
{
- return company._collection?.Insert(warship) ?? false;
+ return company._collection.Insert(warship);
}
///
@@ -68,9 +68,9 @@ public abstract class AbstractCompany
/// Компания
/// Номер удаляемого объекта
///
- public static bool operator -(AbstractCompany company, int position)
+ public static DrawningWarship? operator -(AbstractCompany company, int position)
{
- return company._collection?.Remove(position) ?? false;
+ return company._collection?.Remove(position);
}
///
diff --git a/ProjectAircraftCarrier_/ProjectAircraftCarrier_/CollectionGenericObjects/WarshipSharingService.cs b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/CollectionGenericObjects/Docks.cs
similarity index 88%
rename from ProjectAircraftCarrier_/ProjectAircraftCarrier_/CollectionGenericObjects/WarshipSharingService.cs
rename to ProjectAircraftCarrier_/ProjectAircraftCarrier_/CollectionGenericObjects/Docks.cs
index d0dd03c..44ab95c 100644
--- a/ProjectAircraftCarrier_/ProjectAircraftCarrier_/CollectionGenericObjects/WarshipSharingService.cs
+++ b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/CollectionGenericObjects/Docks.cs
@@ -3,9 +3,9 @@ using ProjectAircraftCarrier_.Drawnings;
namespace ProjectAircraftCarrier_.CollectionGenericObjects;
-public class WarshipSharingService : AbstractCompany
+public class Docks : AbstractCompany
{
- public WarshipSharingService(int picWidth, int picHeight, ICollectionGenericObjects collection) : base(picWidth, picHeight, collection)
+ public Docks(int picWidth, int picHeight, ICollectionGenericObjects collection) : base(picWidth, picHeight, collection)
{
}
diff --git a/ProjectAircraftCarrier_/ProjectAircraftCarrier_/CollectionGenericObjects/ICollectionGenericObjects.cs b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/CollectionGenericObjects/ICollectionGenericObjects.cs
index 2956b5b..c242008 100644
--- a/ProjectAircraftCarrier_/ProjectAircraftCarrier_/CollectionGenericObjects/ICollectionGenericObjects.cs
+++ b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/CollectionGenericObjects/ICollectionGenericObjects.cs
@@ -22,7 +22,7 @@ public interface ICollectionGenericObjects
///
/// Добавляемый объект
/// true - вставка прошла удачно, false - вставка не удалась
- bool Insert(T obj);
+ int Insert(T obj);
///
/// Добавление объекта в коллекцию на конкретную позицию
@@ -30,14 +30,14 @@ public interface ICollectionGenericObjects
/// Добавляемый объект
/// Позиция
/// true - вставка прошла удачно, false - вставка не удалась
- bool Insert(T obj, int position);
+ int Insert(T obj, int position);
///
/// Удаление объекта из коллекции с конкретной позиции
///
/// Позиция
/// true - удаление прошло удачно, false - удаление не удалось
- bool Remove(int position);
+ T? Remove(int position);
///
/// Получение объекта по позиции
diff --git a/ProjectAircraftCarrier_/ProjectAircraftCarrier_/CollectionGenericObjects/MassiveGenericObjects.cs b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/CollectionGenericObjects/MassiveGenericObjects.cs
index edd7ca5..a3c5478 100644
--- a/ProjectAircraftCarrier_/ProjectAircraftCarrier_/CollectionGenericObjects/MassiveGenericObjects.cs
+++ b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/CollectionGenericObjects/MassiveGenericObjects.cs
@@ -34,7 +34,7 @@ public class MassiveGenericObjects : ICollectionGenericObjects
return _collection[position];
}
- public bool Insert(T obj)
+ public int Insert(T obj)
{
// TODO вставка в свободное место набора
for (int i = 0; i < Count; i++)
@@ -42,13 +42,13 @@ public class MassiveGenericObjects : ICollectionGenericObjects
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)
{
// TODO проверка позиции
// TODO проверка, что элемент массива по этой позиции пустой, если нет, то
@@ -57,13 +57,13 @@ public class MassiveGenericObjects : ICollectionGenericObjects
// TODO вставка
if (position < 0 || position > Count)
{
- return false;
+ return -1;
}
if (_collection[position] == null)
{
_collection[position] = obj;
- return true;
+ return position;
}
for (int i = position + 1; i < Count; i++)
@@ -71,7 +71,7 @@ public class MassiveGenericObjects : ICollectionGenericObjects
if (_collection[i] == null)
{
_collection[i] = obj;
- return true;
+ return position;
}
}
@@ -80,24 +80,25 @@ public class MassiveGenericObjects : ICollectionGenericObjects
if (_collection[i] == null)
{
_collection[i] = obj;
- return true;
+ return position;
}
}
- return false;
+ return -1;
}
- public bool Remove(int position)
+ public T? Remove(int position)
{
// TODO проверка позиции
// TODO удаление объекта из массива, присвоив элементу массива значение null
if (position < 0 || position > Count || _collection[position] == null)
{
- return false;
+ return null;
}
+ T? obj = _collection[position];
_collection[position] = null;
- return true;
+ return obj;
}
}
diff --git a/ProjectAircraftCarrier_/ProjectAircraftCarrier_/FormWarshipCollection.cs b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/FormWarshipCollection.cs
index 69a7069..0b2af67 100644
--- a/ProjectAircraftCarrier_/ProjectAircraftCarrier_/FormWarshipCollection.cs
+++ b/ProjectAircraftCarrier_/ProjectAircraftCarrier_/FormWarshipCollection.cs
@@ -31,7 +31,7 @@ public partial class FormWarshipCollection : Form
switch (comboBoxSelectorCompany.Text)
{
case "Хранилище":
- _company = new WarshipSharingService(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects());
+ _company = new Docks(pictureBox.Width, pictureBox.Height, new MassiveGenericObjects());
break;
}
}