diff --git a/AccordionBus/AccordionBus/AbstractMap.cs b/AccordionBus/AccordionBus/AbstractMap.cs index 437ac7f..06068a2 100644 --- a/AccordionBus/AccordionBus/AbstractMap.cs +++ b/AccordionBus/AccordionBus/AbstractMap.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; namespace AccordionBus { - internal abstract class AbstractMap + internal abstract class AbstractMap : IEquatable { private IDrawningObject _drawningObject = null; protected int[,] _map = null; @@ -158,5 +158,45 @@ namespace AccordionBus 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; + } + var otherMap = other as AbstractMap; + if (otherMap == null) + { + return false; + } + if (_width != otherMap._width) + { + return false; + } + if (_height != otherMap._height) + { + return false; + } + if (_size_x != otherMap._size_x) + { + return false; + } + if (_size_y != otherMap._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] != otherMap._map[i, j]) + { + return false; + } + } + } + return true; + } } } \ No newline at end of file