From 6adfe4966994fd313b182553dc60eebdc034f733 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D1=8F=D1=80=20=D0=90=D0=B3=D0=BB?= =?UTF-8?q?=D0=B8=D1=83=D0=BB=D0=BB=D0=BE=D0=B2?= Date: Mon, 31 Oct 2022 07:48:44 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=20Equals=20=D0=B2=20Abs?= =?UTF-8?q?tractMap?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBomber/AirBomber/AbstractMap.cs | 29 ++++++++++++++++++++++++++++- AirBomber/AirBomber/Program.cs | 2 -- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/AirBomber/AirBomber/AbstractMap.cs b/AirBomber/AirBomber/AbstractMap.cs index 62dbec5..b9104c6 100644 --- a/AirBomber/AirBomber/AbstractMap.cs +++ b/AirBomber/AirBomber/AbstractMap.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; namespace AirBomber { - internal abstract class AbstractMap + internal abstract class AbstractMap : IEquatable { private IDrawningObject _drawningObject = null; private Bitmap? _staticBitMap; @@ -174,5 +174,32 @@ namespace AirBomber protected abstract void GenerateMap(); protected abstract void DrawRoadPart(Graphics g, int i, int j); protected abstract void DrawBarrierPart(Graphics g, int i, int j); + + public bool Equals(AbstractMap? other) + { + if (other == null || + _map != other._map || + _width != other._width || + _size_x != other._size_x || + _size_y != other._size_y || + _height != other._height || + GetType() != other.GetType() || + _map.GetLength(0) != other._map.GetLength(0) || + _map.GetLength(1) != other._map.GetLength(1)) + { + return false; + } + for (int i = 0; i < _map.GetLength(0); i++) + { + for (int j = 0; j < _map.GetLength(1); j++) + { + if (_map[i, j] != other._map[i, j]) + { + return false; + } + } + } + return true; + } } } \ No newline at end of file diff --git a/AirBomber/AirBomber/Program.cs b/AirBomber/AirBomber/Program.cs index 4485161..f0821c2 100644 --- a/AirBomber/AirBomber/Program.cs +++ b/AirBomber/AirBomber/Program.cs @@ -17,8 +17,6 @@ namespace AirBomber { // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. - var cmp = new AirplaneCompareByType(); - cmp.Compare(null, null); ApplicationConfiguration.Initialize(); var services = new ServiceCollection(); ConfigureServices(services);