From 63fda8d93d2b1ca47c9312706601d0611bd64ecb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BA=D1=81=20=D0=91=D0=BE=D0=BD=D0=B4=D0=B0?= =?UTF-8?q?=D1=80=D0=B5=D0=BD=D0=BA=D0=BE?= Date: Wed, 2 Nov 2022 09:46:21 +0400 Subject: [PATCH] =?UTF-8?q?=D1=82=D0=B0=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WarmlyShip/WarmlyShip/FormMapWithSetShip.cs | 2 +- WarmlyShip/WarmlyShip/MapWithSetShipGeneric.cs | 2 +- WarmlyShip/WarmlyShip/SetShipGeneric.cs | 9 +++++---- 3 files changed, 7 insertions(+), 6 deletions(-) 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]