Изменен возвращаемый тип
This commit is contained in:
parent
edacc5498e
commit
63b72d2531
@ -55,7 +55,7 @@
|
|||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
DrawningObject airplane = new(form.SelectedAirplane);
|
DrawningObject airplane = new(form.SelectedAirplane);
|
||||||
if (form.SelectedAirplane == null || !(_mapAirplanesCollectionGeneric + airplane))
|
if (form.SelectedAirplane == null || (_mapAirplanesCollectionGeneric + airplane) == -1)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Не удалось добавить объект");
|
MessageBox.Show("Не удалось добавить объект");
|
||||||
}
|
}
|
||||||
@ -82,7 +82,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
|
||||||
if (_mapAirplanesCollectionGeneric - pos)
|
if (_mapAirplanesCollectionGeneric - pos == -1)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Объект удален");
|
MessageBox.Show("Объект удален");
|
||||||
pictureBox.Image = _mapAirplanesCollectionGeneric.ShowSet();
|
pictureBox.Image = _mapAirplanesCollectionGeneric.ShowSet();
|
||||||
|
@ -58,7 +58,7 @@ namespace AirBomber
|
|||||||
/// <param name="map"></param>
|
/// <param name="map"></param>
|
||||||
/// <param name="airplane"></param>
|
/// <param name="airplane"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool operator +(MapWithSetAirplanesGeneric<T, U> map, T airplane)
|
public static int operator +(MapWithSetAirplanesGeneric<T, U> map, T airplane)
|
||||||
{
|
{
|
||||||
return map._setAirplanes.Insert(airplane);
|
return map._setAirplanes.Insert(airplane);
|
||||||
}
|
}
|
||||||
@ -68,7 +68,7 @@ namespace AirBomber
|
|||||||
/// <param name="map"></param>
|
/// <param name="map"></param>
|
||||||
/// <param name="position"></param>
|
/// <param name="position"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool operator -(MapWithSetAirplanesGeneric<T, U> map, int position)
|
public static int operator -(MapWithSetAirplanesGeneric<T, U> map, int position)
|
||||||
{
|
{
|
||||||
return map._setAirplanes.Remove(position);
|
return map._setAirplanes.Remove(position);
|
||||||
}
|
}
|
||||||
|
@ -33,8 +33,8 @@ namespace AirBomber
|
|||||||
/// Добавление объекта в набор
|
/// Добавление объекта в набор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="airplane">Добавляемый самолет</param>
|
/// <param name="airplane">Добавляемый самолет</param>
|
||||||
/// <returns></returns>
|
/// <returns>Возвращает позицию вставленого объекта либо -1, если не получилось его добавить</returns>
|
||||||
public bool Insert(T airplane)
|
public int Insert(T airplane)
|
||||||
{
|
{
|
||||||
return Insert(airplane, 0);
|
return Insert(airplane, 0);
|
||||||
}
|
}
|
||||||
@ -48,8 +48,8 @@ namespace AirBomber
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="airplane">Добавляемый самолет</param>
|
/// <param name="airplane">Добавляемый самолет</param>
|
||||||
/// <param name="position">Позиция</param>
|
/// <param name="position">Позиция</param>
|
||||||
/// <returns></returns>
|
/// <returns>Возвращает позицию вставленого объекта либо -1, если не получилось его добавить</returns>
|
||||||
public bool Insert(T airplane, int position)
|
public int Insert(T airplane, int position)
|
||||||
{
|
{
|
||||||
int positionNullElement = position;
|
int positionNullElement = position;
|
||||||
while (Get(positionNullElement) != null)
|
while (Get(positionNullElement) != null)
|
||||||
@ -59,7 +59,7 @@ namespace AirBomber
|
|||||||
// Если изначальная позиция была некорректной или пустых элементов справа не оказалось возвращаем false
|
// Если изначальная позиция была некорректной или пустых элементов справа не оказалось возвращаем false
|
||||||
if (!isCorrectPosition(positionNullElement))
|
if (!isCorrectPosition(positionNullElement))
|
||||||
{
|
{
|
||||||
return false;
|
return -1;
|
||||||
}
|
}
|
||||||
while (positionNullElement != position) // Смещение вправо
|
while (positionNullElement != position) // Смещение вправо
|
||||||
{
|
{
|
||||||
@ -67,19 +67,19 @@ namespace AirBomber
|
|||||||
positionNullElement--;
|
positionNullElement--;
|
||||||
}
|
}
|
||||||
_places[position] = airplane;
|
_places[position] = airplane;
|
||||||
return true;
|
return position;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Удаление объекта из набора с конкретной позиции
|
/// Удаление объекта из набора с конкретной позиции
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="position"></param>
|
/// <param name="position"></param>
|
||||||
/// <returns></returns>
|
/// <returns>Возвращает позицию вставленого объекта либо -1, если не получилось его добавить</returns>
|
||||||
public bool Remove(int position)
|
public int Remove(int position)
|
||||||
{
|
{
|
||||||
if (!isCorrectPosition(position))
|
if (!isCorrectPosition(position))
|
||||||
return false;
|
return -1;
|
||||||
_places[position] = null;
|
_places[position] = null;
|
||||||
return true;
|
return position;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение объекта из набора по позиции
|
/// Получение объекта из набора по позиции
|
||||||
|
Loading…
Reference in New Issue
Block a user