From 6a6a24f7dc8cfe1870d392b1d4aea314af6592c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=9F=D0=BE=D0=BB?= =?UTF-8?q?=D0=B5=D0=B2=D0=BE=D0=B9?= Date: Mon, 21 Nov 2022 20:30:27 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20=D0=B3?= =?UTF-8?q?=D0=BE=D1=82=D0=BE=D0=B2=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SelfPropelledArtilleryUnit/AbstractMap.cs | 43 ++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/SelfPropelledArtilleryUnit/AbstractMap.cs b/SelfPropelledArtilleryUnit/AbstractMap.cs index ac916bb..5fe392f 100644 --- a/SelfPropelledArtilleryUnit/AbstractMap.cs +++ b/SelfPropelledArtilleryUnit/AbstractMap.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace Artilleries { - internal abstract class AbstractMap + internal abstract class AbstractMap : IEquatable { private IDrawingObject _drawingObject = null; protected int[,] _map = null; @@ -122,5 +122,46 @@ namespace Artilleries 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) + { + return false; + } + + if (_width != other._width) + { + return false; + } + + if (_height != other._height) + { + return false; + } + + if (_size_x != other._size_x) + { + return false; + } + + if (_size_y != other._size_y) + { + 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; + } } }