переопределение
This commit is contained in:
parent
b576a536db
commit
146d39f5f0
@ -32,7 +32,7 @@ DrawningObjectShip>(pictureBoxCollection.Width, pictureBoxCollection.Height);
|
||||
FormContainerShip form = new FormContainerShip();
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (_ships + form.SelectedShip)
|
||||
if (_ships + form.SelectedShip != -1)
|
||||
{
|
||||
MessageBox.Show("Объект добавлен");
|
||||
pictureBoxCollection.Image = _ships.ShowShips();
|
||||
|
@ -9,6 +9,7 @@ namespace Lab1ContainersShip
|
||||
{
|
||||
public class SetGeneric<T>
|
||||
where T : class
|
||||
|
||||
{
|
||||
// <summary>
|
||||
/// Массив объектов, которые храним
|
||||
@ -31,7 +32,7 @@ namespace Lab1ContainersShip
|
||||
/// </summary>
|
||||
/// <param name="car">Добавляемый автомобиль</param>
|
||||
/// <returns></returns>
|
||||
public bool Insert(T ship)
|
||||
public int Insert(T ship)
|
||||
{
|
||||
// TODO вставка в начало набора
|
||||
int temp = 0;
|
||||
@ -44,7 +45,7 @@ namespace Lab1ContainersShip
|
||||
}
|
||||
if (k == _places.Length)
|
||||
{
|
||||
return false;
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -63,7 +64,7 @@ namespace Lab1ContainersShip
|
||||
|
||||
}
|
||||
_places[0] = ship;
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
@ -155,6 +156,6 @@ namespace Lab1ContainersShip
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -52,14 +52,14 @@ namespace Lab1ContainersShip
|
||||
/// <param name="collect"></param>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
public static bool operator +(ShipGenericCollection<T, U> collect, T
|
||||
public static int operator +(ShipGenericCollection<T, U> collect, T
|
||||
obj)
|
||||
{
|
||||
if (obj == null)
|
||||
{
|
||||
return false;
|
||||
return -1;
|
||||
}
|
||||
return collect?._collection.Insert(obj) ?? false;
|
||||
return collect?._collection.Insert(obj) ?? -1;
|
||||
}
|
||||
/// <summary>
|
||||
/// Перегрузка оператора вычитания
|
||||
|
Loading…
Reference in New Issue
Block a user