Финал

This commit is contained in:
Nap 2022-12-09 01:44:21 +04:00
parent a04ab48038
commit 7c7fe34520

View File

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace Battleship
{
internal abstract class AbstractMap
internal abstract class AbstractMap : IEquatable<AbstractMap>
{
private IDrawningObject _drawingObject = null;
protected int[,] _map = null;
@ -124,6 +124,29 @@ namespace Battleship
return false;
}
public bool Equals(AbstractMap? other)
{
if (other == null || _map != other._map || _height != other._height || _width != other._width
|| _size_x != other._size_x || _size_y != other._size_y || 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;
}
protected abstract void GenerateMap();
protected abstract void DrawRoadPart(Graphics g, int i, int j);
protected abstract void DrawBarrierPart(Graphics g, int i, int j);