diff --git a/WarmlyShip/WarmlyShip/FormMapWithSetShip.cs b/WarmlyShip/WarmlyShip/FormMapWithSetShip.cs index 489e6cd..e821865 100644 --- a/WarmlyShip/WarmlyShip/FormMapWithSetShip.cs +++ b/WarmlyShip/WarmlyShip/FormMapWithSetShip.cs @@ -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 = diff --git a/WarmlyShip/WarmlyShip/MapWithSetShipGeneric.cs b/WarmlyShip/WarmlyShip/MapWithSetShipGeneric.cs index 3efe986..01d1c4c 100644 --- a/WarmlyShip/WarmlyShip/MapWithSetShipGeneric.cs +++ b/WarmlyShip/WarmlyShip/MapWithSetShipGeneric.cs @@ -32,7 +32,7 @@ namespace WarmlyShip return map._setShips.Insert(ship); } - public static int operator -(MapWithSetShipGeneric map, int position) + public static T operator -(MapWithSetShipGeneric map, int position) { return map._setShips.Remove(position); } diff --git a/WarmlyShip/WarmlyShip/SetShipGeneric.cs b/WarmlyShip/WarmlyShip/SetShipGeneric.cs index 5be0511..7d336d8 100644 --- a/WarmlyShip/WarmlyShip/SetShipGeneric.cs +++ b/WarmlyShip/WarmlyShip/SetShipGeneric.cs @@ -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]