Лабораторная работa 3
This commit is contained in:
parent
681e60fbd6
commit
feea0da22b
@ -41,9 +41,9 @@ namespace HoistingCrane.CollectionGenericObjects
|
||||
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)
|
||||
{
|
||||
|
@ -16,14 +16,14 @@
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
T? Insert(T obj);
|
||||
int Insert(T obj);
|
||||
/// <summary>
|
||||
/// Добавление элемента в коллекцию на определенную позицию
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <param name="position"></param>
|
||||
/// <returns></returns>
|
||||
T? Insert(T obj, int position);
|
||||
int Insert(T obj, int position);
|
||||
/// <summary>
|
||||
/// Удаление элемента из коллекции по его позиции
|
||||
/// </summary>
|
||||
|
@ -30,7 +30,7 @@
|
||||
return null;
|
||||
}
|
||||
|
||||
public T? Insert(T obj)
|
||||
public int Insert(T obj)
|
||||
{
|
||||
for (int i = 0; i < Count; i++)
|
||||
{
|
||||
@ -39,34 +39,34 @@
|
||||
return Insert(obj, 0);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return -1;
|
||||
}
|
||||
|
||||
public T? Insert(T obj, int position)
|
||||
public int Insert(T obj, int position)
|
||||
{
|
||||
//todo Проверка позиции
|
||||
if (position < 0 || position > Count)
|
||||
{
|
||||
return null;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (arr[position] == null)
|
||||
{
|
||||
arr[position] = obj;
|
||||
return arr[position];
|
||||
return position;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Insert(obj, position + 1) != null)
|
||||
{
|
||||
return arr[position + 1];
|
||||
return position;
|
||||
}
|
||||
if (Insert(obj, position - 1) != null)
|
||||
{
|
||||
return arr[position - 1];
|
||||
return position;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return -1;
|
||||
}
|
||||
|
||||
public T? Remove(int position)
|
||||
|
@ -38,7 +38,7 @@ namespace HoistingCrane
|
||||
default:
|
||||
return;
|
||||
}
|
||||
if ((_company + drawning) != null)
|
||||
if ((_company + drawning) != -1)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBox.Image = _company.Show();
|
||||
|
Loading…
Reference in New Issue
Block a user