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;
|
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)
|
public static DrawningTrackedVehicle operator -(AbstractCompany company, int position)
|
||||||
{
|
{
|
||||||
|
@ -16,14 +16,14 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="obj"></param>
|
/// <param name="obj"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
int Insert(T obj);
|
T? 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>
|
||||||
int Insert(T obj, int position);
|
T? Insert(T obj, int position);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Удаление элемента из коллекции по его позиции
|
/// Удаление элемента из коллекции по его позиции
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Insert(T obj)
|
public T? 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 -1;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Insert(T obj, int position)
|
public T? Insert(T obj, int position)
|
||||||
{
|
{
|
||||||
//todo Проверка позиции
|
//todo Проверка позиции
|
||||||
if (position < 0 || position > Count)
|
if (position < 0 || position > Count)
|
||||||
{
|
{
|
||||||
return -1;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arr[position] == null)
|
if (arr[position] == null)
|
||||||
{
|
{
|
||||||
arr[position] = obj;
|
arr[position] = obj;
|
||||||
return position;
|
return arr[position];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (Insert(obj, position + 1) != null)
|
if (Insert(obj, position + 1) != null)
|
||||||
{
|
{
|
||||||
return position;
|
return arr[position + 1];
|
||||||
}
|
}
|
||||||
if (Insert(obj, position - 1) != null)
|
if (Insert(obj, position - 1) != null)
|
||||||
{
|
{
|
||||||
return position;
|
return arr[position - 1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public T? Remove(int position)
|
public T? Remove(int position)
|
||||||
|
@ -38,7 +38,7 @@ namespace HoistingCrane
|
|||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((_company + drawning) != -1)
|
if ((_company + drawning) != null)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Объект добавлен");
|
MessageBox.Show("Объект добавлен");
|
||||||
pictureBox.Image = _company.Show();
|
pictureBox.Image = _company.Show();
|
||||||
|
Loading…
Reference in New Issue
Block a user