This commit is contained in:
Макс Бондаренко 2022-11-02 09:46:21 +04:00
parent 0613fd9196
commit 63fda8d93d
3 changed files with 7 additions and 6 deletions

View File

@ -124,7 +124,7 @@ namespace WarmlyShip
return;
}
int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] - pos == 1)
if (_mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty] - pos != null)
{
MessageBox.Show("Объект удален");
pictureBox.Image =

View File

@ -32,7 +32,7 @@ namespace WarmlyShip
return map._setShips.Insert(ship);
}
public static int operator -(MapWithSetShipGeneric<T, U> map, int position)
public static T operator -(MapWithSetShipGeneric<T, U> map, int position)
{
return map._setShips.Remove(position);
}

View File

@ -27,15 +27,16 @@ namespace WarmlyShip
public int Insert(T ship, int position)
{
if (position < 0 || position > Count || Count == _maxCount) return 0;
if (position < 0 || position > Count || Count == _maxCount) return -1;
_places.Insert(position, ship);
return 1;
return position;
}
public int Remove(int position)
public T Remove(int position)
{
T DelElement = _places[position];
_places[position] = null;
return 1;
return DelElement;
}
public T this[int position]