Compare commits

..

2 Commits

4 changed files with 13 additions and 13 deletions

View File

@ -41,9 +41,9 @@ namespace HoistingCrane.CollectionGenericObjects
arr.SetMaxCount = GetMaxCount; 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) public static DrawningTrackedVehicle operator -(AbstractCompany company, int position)
{ {

View File

@ -16,14 +16,14 @@
/// </summary> /// </summary>
/// <param name="obj"></param> /// <param name="obj"></param>
/// <returns></returns> /// <returns></returns>
T? Insert(T obj); int Insert(T obj);
/// <summary> /// <summary>
/// Добавление элемента в коллекцию на определенную позицию /// Добавление элемента в коллекцию на определенную позицию
/// </summary> /// </summary>
/// <param name="obj"></param> /// <param name="obj"></param>
/// <param name="position"></param> /// <param name="position"></param>
/// <returns></returns> /// <returns></returns>
T? Insert(T obj, int position); int Insert(T obj, int position);
/// <summary> /// <summary>
/// Удаление элемента из коллекции по его позиции /// Удаление элемента из коллекции по его позиции
/// </summary> /// </summary>

View File

@ -30,7 +30,7 @@
return null; return null;
} }
public T? Insert(T obj) public int Insert(T obj)
{ {
for (int i = 0; i < Count; i++) for (int i = 0; i < Count; i++)
{ {
@ -39,34 +39,34 @@
return Insert(obj, 0); return Insert(obj, 0);
} }
} }
return null; return -1;
} }
public T? Insert(T obj, int position) public int Insert(T obj, int position)
{ {
//todo Проверка позиции //todo Проверка позиции
if (position < 0 || position > Count) if (position < 0 || position > Count)
{ {
return null; return -1;
} }
if (arr[position] == null) if (arr[position] == null)
{ {
arr[position] = obj; arr[position] = obj;
return arr[position]; return position;
} }
else else
{ {
if (Insert(obj, position + 1) != null) if (Insert(obj, position + 1) != null)
{ {
return arr[position + 1]; return position;
} }
if (Insert(obj, position - 1) != null) if (Insert(obj, position - 1) != null)
{ {
return arr[position - 1]; return position;
} }
} }
return null; return -1;
} }
public T? Remove(int position) public T? Remove(int position)

View File

@ -38,7 +38,7 @@ namespace HoistingCrane
default: default:
return; return;
} }
if ((_company + drawning) != null) if ((_company + drawning) != -1)
{ {
MessageBox.Show("Объект добавлен"); MessageBox.Show("Объект добавлен");
pictureBox.Image = _company.Show(); pictureBox.Image = _company.Show();