From 319fa1298db684f0c661da60e44b5121efd0e540 Mon Sep 17 00:00:00 2001 From: AnnaLioness Date: Fri, 20 Oct 2023 17:36:21 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Lab1ContainersShip/Lab1ContainersShip/FormShipCollection.cs | 2 +- .../Lab1ContainersShip/ShipGenericCollection.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Lab1ContainersShip/Lab1ContainersShip/FormShipCollection.cs b/Lab1ContainersShip/Lab1ContainersShip/FormShipCollection.cs index e2065c7..c8f1303 100644 --- a/Lab1ContainersShip/Lab1ContainersShip/FormShipCollection.cs +++ b/Lab1ContainersShip/Lab1ContainersShip/FormShipCollection.cs @@ -53,7 +53,7 @@ MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) return; } int pos = Convert.ToInt32(maskedTextBoxNumber.Text); - if (_ships - pos != null) + if (!(_ships - pos)) { MessageBox.Show("Объект удален"); pictureBoxCollection.Image = _ships.ShowShips(); diff --git a/Lab1ContainersShip/Lab1ContainersShip/ShipGenericCollection.cs b/Lab1ContainersShip/Lab1ContainersShip/ShipGenericCollection.cs index 4c7bfed..c8272cd 100644 --- a/Lab1ContainersShip/Lab1ContainersShip/ShipGenericCollection.cs +++ b/Lab1ContainersShip/Lab1ContainersShip/ShipGenericCollection.cs @@ -67,15 +67,15 @@ namespace Lab1ContainersShip /// /// /// - public static T operator -(ShipGenericCollection collect, int + public static bool operator -(ShipGenericCollection collect, int pos) { T obj = collect._collection.Get(pos); if (obj != null) { - collect._collection.Remove(pos); + return collect._collection.Remove(pos); } - return obj; + return false; } /// /// Получение объекта IMoveableObject