fix last todo

This commit is contained in:
NikGapon 2022-11-08 18:38:04 +04:00
parent 5aaae123bd
commit 49bcf52b3a
3 changed files with 13 additions and 10 deletions

View File

@ -69,7 +69,7 @@ namespace Airbus
if (form.ShowDialog() == DialogResult.OK)
{
DrawningObjectAirplane airplane = new(form.SelectedAirplane);
if (_mapAirplanesCollectionGeneric + airplane)
if (_mapAirplanesCollectionGeneric + airplane > -1)
{
MessageBox.Show("Объект добавлен");
pictureBox.Image = _mapAirplanesCollectionGeneric.ShowSet();
@ -97,7 +97,7 @@ namespace Airbus
return;
}
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
if (_mapAirplanesCollectionGeneric - pos)
if (_mapAirplanesCollectionGeneric - pos != null )
{
MessageBox.Show("Объект удален");
pictureBox.Image = _mapAirplanesCollectionGeneric.ShowSet();

View File

@ -55,7 +55,7 @@ namespace Airbus
/// <param name="map"></param>
/// <param name="car"></param>
/// <returns></returns>
public static bool operator +(MapWithSetAirplaneGeneric<T, U> map, T airplane)
public static int operator +(MapWithSetAirplaneGeneric<T, U> map, T airplane)
{
return map._setAirplane.Insert(airplane);
}
@ -65,7 +65,7 @@ namespace Airbus
/// <param name="map"></param>
/// <param name="position"></param>
/// <returns></returns>
public static bool operator -(MapWithSetAirplaneGeneric<T, U> map, int
public static T operator -(MapWithSetAirplaneGeneric<T, U> map, int
position)
{
return map._setAirplane.Remove(position);

View File

@ -30,14 +30,14 @@ namespace Airbus
return false;
}
public bool Insert(T airplane)
public int Insert(T airplane)
{
return Insert(airplane, 0);
}
public bool Insert(T airplane, int position)
public int Insert(T airplane, int position)
{
if (position < 0 || position > _places.Length) return false;
if (position < 0 || position > _places.Length) return 0;
if (_places[position] != null && CanInsert(position))
{
for (int i = _places.Length - 1; i > position; --i)
@ -50,17 +50,20 @@ namespace Airbus
}
}
_places[position] = airplane;
return true;
return 1;
}
/// <summary>
/// Удаление объекта из набора с конкретной позиции
/// </summary>
/// <param name="position"></param>
/// <returns></returns>
public bool Remove(int position)
public T Remove(int position)
{
if (0 > position && position >= Count)
return null;
T delobj = _places[position];
_places[position] = null;
return true;
return delobj;
}
/// <summary>
/// Получение объекта из набора по позиции