Compare commits
No commits in common. "92f30977afe17f88dff848571751aefa0356c482" and "4eeaacde4b82528b669ad68014da836072d8b12c" have entirely different histories.
92f30977af
...
4eeaacde4b
@ -41,9 +41,9 @@ namespace HoistingCrane.CollectionGenericObjects
|
||||
arr.SetMaxCount = GetMaxCount;
|
||||
}
|
||||
|
||||
public static int operator +(AbstractCompany company, DrawningTrackedVehicle car)
|
||||
public static DrawningTrackedVehicle operator +(AbstractCompany company, DrawningTrackedVehicle car)
|
||||
{
|
||||
return company.arr?.Insert(car) ?? -1;
|
||||
return company.arr?.Insert(car) ?? null;
|
||||
}
|
||||
public static DrawningTrackedVehicle operator -(AbstractCompany company, int position)
|
||||
{
|
||||
|
@ -16,14 +16,14 @@
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
int Insert(T obj);
|
||||
T? Insert(T obj);
|
||||
/// <summary>
|
||||
/// Добавление элемента в коллекцию на определенную позицию
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <param name="position"></param>
|
||||
/// <returns></returns>
|
||||
int Insert(T obj, int position);
|
||||
T? Insert(T obj, int position);
|
||||
/// <summary>
|
||||
/// Удаление элемента из коллекции по его позиции
|
||||
/// </summary>
|
||||
|
@ -30,7 +30,7 @@
|
||||
return null;
|
||||
}
|
||||
|
||||
public int Insert(T obj)
|
||||
public T? Insert(T obj)
|
||||
{
|
||||
for (int i = 0; i < Count; i++)
|
||||
{
|
||||
@ -39,34 +39,34 @@
|
||||
return Insert(obj, 0);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
return null;
|
||||
}
|
||||
|
||||
public int Insert(T obj, int position)
|
||||
public T? Insert(T obj, int position)
|
||||
{
|
||||
//todo Проверка позиции
|
||||
if (position < 0 || position > Count)
|
||||
{
|
||||
return -1;
|
||||
return null;
|
||||
}
|
||||
|
||||
if (arr[position] == null)
|
||||
{
|
||||
arr[position] = obj;
|
||||
return position;
|
||||
return arr[position];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Insert(obj, position + 1) != null)
|
||||
{
|
||||
return position;
|
||||
return arr[position + 1];
|
||||
}
|
||||
if (Insert(obj, position - 1) != null)
|
||||
{
|
||||
return position;
|
||||
return arr[position - 1];
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
return null;
|
||||
}
|
||||
|
||||
public T? Remove(int position)
|
||||
|
@ -38,7 +38,7 @@ namespace HoistingCrane
|
||||
default:
|
||||
return;
|
||||
}
|
||||
if ((_company + drawning) != -1)
|
||||
if ((_company + drawning) != null)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBox.Image = _company.Show();
|
||||
|
Loading…
Reference in New Issue
Block a user