Изменен возвращаемый тип

This commit is contained in:
the 2022-10-05 12:05:46 +04:00
parent edacc5498e
commit 63b72d2531
3 changed files with 14 additions and 14 deletions

View File

@ -55,7 +55,7 @@
if (form.ShowDialog() == DialogResult.OK)
{
DrawningObject airplane = new(form.SelectedAirplane);
if (form.SelectedAirplane == null || !(_mapAirplanesCollectionGeneric + airplane))
if (form.SelectedAirplane == null || (_mapAirplanesCollectionGeneric + airplane) == -1)
{
MessageBox.Show("Не удалось добавить объект");
}
@ -82,7 +82,7 @@
return;
}
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
if (_mapAirplanesCollectionGeneric - pos)
if (_mapAirplanesCollectionGeneric - pos == -1)
{
MessageBox.Show("Объект удален");
pictureBox.Image = _mapAirplanesCollectionGeneric.ShowSet();

View File

@ -58,7 +58,7 @@ namespace AirBomber
/// <param name="map"></param>
/// <param name="airplane"></param>
/// <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);
}
@ -68,7 +68,7 @@ namespace AirBomber
/// <param name="map"></param>
/// <param name="position"></param>
/// <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);
}

View File

@ -33,8 +33,8 @@ namespace AirBomber
/// Добавление объекта в набор
/// </summary>
/// <param name="airplane">Добавляемый самолет</param>
/// <returns></returns>
public bool Insert(T airplane)
/// <returns>Возвращает позицию вставленого объекта либо -1, если не получилось его добавить</returns>
public int Insert(T airplane)
{
return Insert(airplane, 0);
}
@ -48,8 +48,8 @@ namespace AirBomber
/// </summary>
/// <param name="airplane">Добавляемый самолет</param>
/// <param name="position">Позиция</param>
/// <returns></returns>
public bool Insert(T airplane, int position)
/// <returns>Возвращает позицию вставленого объекта либо -1, если не получилось его добавить</returns>
public int Insert(T airplane, int position)
{
int positionNullElement = position;
while (Get(positionNullElement) != null)
@ -59,7 +59,7 @@ namespace AirBomber
// Если изначальная позиция была некорректной или пустых элементов справа не оказалось возвращаем false
if (!isCorrectPosition(positionNullElement))
{
return false;
return -1;
}
while (positionNullElement != position) // Смещение вправо
{
@ -67,19 +67,19 @@ namespace AirBomber
positionNullElement--;
}
_places[position] = airplane;
return true;
return position;
}
/// <summary>
/// Удаление объекта из набора с конкретной позиции
/// </summary>
/// <param name="position"></param>
/// <returns></returns>
public bool Remove(int position)
/// <returns>Возвращает позицию вставленого объекта либо -1, если не получилось его добавить</returns>
public int Remove(int position)
{
if (!isCorrectPosition(position))
return false;
return -1;
_places[position] = null;
return true;
return position;
}
/// <summary>
/// Получение объекта из набора по позиции