diff --git a/DoubleDeckerBus/DoubleDeckerBus/CollectionGenericObjects/AbstractCompany.cs b/DoubleDeckerBus/DoubleDeckerBus/CollectionGenericObjects/AbstractCompany.cs
index 6693ce4..0ab649f 100644
--- a/DoubleDeckerBus/DoubleDeckerBus/CollectionGenericObjects/AbstractCompany.cs
+++ b/DoubleDeckerBus/DoubleDeckerBus/CollectionGenericObjects/AbstractCompany.cs
@@ -64,9 +64,9 @@ public abstract class AbstractCompany
/// Компания
/// Добавляемый объект
///
- public static bool operator +(AbstractCompany company, DrawingBus bus)
+ public static int? operator +(AbstractCompany company, DrawingBus bus)
{
- return company._collection?.Insert(bus) ?? false;
+ return company._collection?.Insert(bus);
}
///
@@ -75,9 +75,9 @@ public abstract class AbstractCompany
/// Компания
/// Номер удаляемого объекта
///
- public static bool operator -(AbstractCompany company, int position)
+ public static DrawingBus? operator -(AbstractCompany company, int position)
{
- return company._collection?.Remove(position) ?? false;
+ return company._collection?.Remove(position);
}
public DrawingBus? GetRandomObject()
diff --git a/DoubleDeckerBus/DoubleDeckerBus/CollectionGenericObjects/BusStation.cs b/DoubleDeckerBus/DoubleDeckerBus/CollectionGenericObjects/BusStation.cs
index 3e598d3..cc974ed 100644
--- a/DoubleDeckerBus/DoubleDeckerBus/CollectionGenericObjects/BusStation.cs
+++ b/DoubleDeckerBus/DoubleDeckerBus/CollectionGenericObjects/BusStation.cs
@@ -21,9 +21,9 @@ public class BusStation : AbstractCompany
Pen pen = new Pen(Color.Black, 3);
int gap = 15;
- int y = 10;
+ int y = gap;
int size_of_array = 2;
-
+
while (y + _placeSizeHeight < _pictureHeight - gap)
{
int x = _pictureWidth - gap;
@@ -35,13 +35,13 @@ public class BusStation : AbstractCompany
g.DrawLine(pen, x, y + _placeSizeHeight, x - _placeSizeWidth, y + _placeSizeHeight);
Array.Resize(ref _arrayOfCoordinates, size_of_array);
- _arrayOfCoordinates[size_of_array - 2] = x;
- _arrayOfCoordinates[size_of_array - 1] = y;
+ _arrayOfCoordinates[size_of_array - 2] = x - 120;
+ _arrayOfCoordinates[size_of_array - 1] = y + gap;
- x -= (_placeSizeWidth + 70);
+ x -= (_placeSizeWidth + (_placeSizeWidth/2));
+ size_of_array += 2;
}
y += _placeSizeHeight;
- size_of_array += 2;
}
}
diff --git a/DoubleDeckerBus/DoubleDeckerBus/CollectionGenericObjects/ICollectionGenericObjects.cs b/DoubleDeckerBus/DoubleDeckerBus/CollectionGenericObjects/ICollectionGenericObjects.cs
index 8c67a07..b5d541d 100644
--- a/DoubleDeckerBus/DoubleDeckerBus/CollectionGenericObjects/ICollectionGenericObjects.cs
+++ b/DoubleDeckerBus/DoubleDeckerBus/CollectionGenericObjects/ICollectionGenericObjects.cs
@@ -28,7 +28,7 @@ public interface ICollectionGenericObjects
///
/// Добавляемый объект
/// true - вставка прошла успешно, false - вставка не удалась
- bool Insert(T obj);
+ int Insert(T obj);
///
/// Добавление элемента на конкретную позицию
@@ -36,14 +36,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/DoubleDeckerBus/DoubleDeckerBus/CollectionGenericObjects/MassiveGenericObjects.cs b/DoubleDeckerBus/DoubleDeckerBus/CollectionGenericObjects/MassiveGenericObjects.cs
index 2c40eb9..16ceba5 100644
--- a/DoubleDeckerBus/DoubleDeckerBus/CollectionGenericObjects/MassiveGenericObjects.cs
+++ b/DoubleDeckerBus/DoubleDeckerBus/CollectionGenericObjects/MassiveGenericObjects.cs
@@ -39,7 +39,7 @@ public class MassiveGenericObjects : ICollectionGenericObjects
_collection = Array.Empty();
}
- public T? Get(int position)//возможно придётся доделать
+ public T? Get(int position)
{
if (position < 0 || position > Count)
{
@@ -49,50 +49,53 @@ public class MassiveGenericObjects : ICollectionGenericObjects
}
- public bool Insert(T obj)
+ public int Insert(T obj)
{
- if (Insert(obj, 0))
- {
- return true;
- }
- return false;
+ return Insert(obj, 0);
}
- public bool Insert(T obj, int position)
+ public int Insert(T obj, int position)
{
- //проверка позиции
+
if (position < 0 || position > Count)
{
- return false;
+ return -1;
}
- if (_collection[position] == null)
+ int copy_of_position = position - 1;
+
+ while (position < Count)
{
- _collection[position] = obj;
- return true;
+ if (_collection[position] == null)
+ {
+ _collection[position] = obj;
+ return position;
+ }
+ position++;
}
- else
+ while (copy_of_position > 0)
{
- if (Insert(obj, position + 1))
+ if (_collection[position] == null)
{
- return true;
- }
- if (Insert(obj, position - 1))
- {
- return true;
+ _collection[position] = obj;
+ return position;
}
+ position--;
}
- return false;
+
+ return -1;
}
- public bool Remove(int position)
+ public T? Remove(int position)
{
if (position < 0 || position > Count)
{
- return false;
+ return null;
}
+
+ T? removed_object = _collection[position];
_collection[position] = null;
- return true;
+ return removed_object;
}
}
diff --git a/DoubleDeckerBus/DoubleDeckerBus/FormBusCollection.cs b/DoubleDeckerBus/DoubleDeckerBus/FormBusCollection.cs
index 037219a..fb2f7aa 100644
--- a/DoubleDeckerBus/DoubleDeckerBus/FormBusCollection.cs
+++ b/DoubleDeckerBus/DoubleDeckerBus/FormBusCollection.cs
@@ -58,7 +58,7 @@ public partial class FormBusCollection : Form
return;
}
- if (_company + drawingBus)
+ if ((_company + drawingBus) != -1)
{
MessageBox.Show("Object added");
pictureBox.Image = _company.Show();
@@ -98,7 +98,7 @@ public partial class FormBusCollection : Form
}
int pos = Convert.ToInt32(maskedTextBox.Text);
- if (_company - pos)
+ if (_company - pos != null)
{
MessageBox.Show("Object removed");
pictureBox.Image = _company.Show();