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; + } } }