Работа готова

This commit is contained in:
Сергей Полевой 2022-11-21 20:30:27 +04:00
parent 402fb1d315
commit 6a6a24f7dc

View File

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace Artilleries
{
internal abstract class AbstractMap
internal abstract class AbstractMap : IEquatable<AbstractMap>
{
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;
}
}
}