From 7baa0393e08afa1ad6ef09a3c9f4facc83b4a24f Mon Sep 17 00:00:00 2001 From: grishazagidulin Date: Sun, 28 Apr 2024 17:02:12 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A4=D0=B8=D0=BA=D1=81=20ObjNotFndEx=20=D0=B2?= =?UTF-8?q?=20=D0=BA=D0=BE=D0=BC=D0=BF=D0=B0=D0=BD=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CollectionGenericObjects/AbstractCompany.cs | 9 +++++++-- .../Battleship/CollectionGenericObjects/ShipDocks.cs | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Battleship/Battleship/CollectionGenericObjects/AbstractCompany.cs b/Battleship/Battleship/CollectionGenericObjects/AbstractCompany.cs index 1fd9715..7495e55 100644 --- a/Battleship/Battleship/CollectionGenericObjects/AbstractCompany.cs +++ b/Battleship/Battleship/CollectionGenericObjects/AbstractCompany.cs @@ -1,4 +1,5 @@ using Battleship.Drawnings; +using Battleship.Exceptions; namespace Battleship.CollectionGenericObjects; /// @@ -94,8 +95,12 @@ public abstract class AbstractCompany SetObjectsPosition(); for (int i = 0; i < (_collection?.Count ?? 0); ++i) { - DrawningShip? obj = _collection?.Get(i); - obj?.DrawTransport(graphics); + try + { + DrawningShip? obj = _collection?.Get(i); + obj?.DrawTransport(graphics); + } + catch (ObjectNotFoundException) { }; } return bitmap; } diff --git a/Battleship/Battleship/CollectionGenericObjects/ShipDocks.cs b/Battleship/Battleship/CollectionGenericObjects/ShipDocks.cs index ab9fcbc..afd2833 100644 --- a/Battleship/Battleship/CollectionGenericObjects/ShipDocks.cs +++ b/Battleship/Battleship/CollectionGenericObjects/ShipDocks.cs @@ -1,4 +1,5 @@ using Battleship.Drawnings; +using Battleship.Exceptions; using System; using System.Collections.Generic; using System.Linq; @@ -50,8 +51,12 @@ public class ShipDocks : AbstractCompany { if (count < _collection.Count) { - _collection?.Get(count)?.SetPictureSize(_pictureWidth, _pictureHeight); - _collection?.Get(count)?.SetPosition(ix, iy); + try + { + _collection?.Get(count)?.SetPictureSize(_pictureWidth, _pictureHeight); + _collection?.Get(count)?.SetPosition(ix, iy); + } + catch (ObjectNotFoundException){} } count++; }