корректировка abstractmap
This commit is contained in:
parent
bd479e2faf
commit
48eef0fb16
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace ContainerShip
|
||||
{
|
||||
internal abstract class AbstractMap
|
||||
internal abstract class AbstractMap : IEquatable<AbstractMap>
|
||||
{
|
||||
private IDrawingObject _drawningObject = null;
|
||||
protected int[,] _map = null;
|
||||
@ -217,5 +217,32 @@ namespace ContainerShip
|
||||
protected abstract void GenerateMap();
|
||||
protected abstract void DrawWaterPart(Graphics g, int i, int j);
|
||||
protected abstract void DrawBarrierPart(Graphics g, int i, int j);
|
||||
|
||||
public bool Equals(AbstractMap? other)
|
||||
{
|
||||
if (other == null ||
|
||||
_map != other._map ||
|
||||
_width != other._width ||
|
||||
_size_x != other._size_x ||
|
||||
_size_y != other._size_y ||
|
||||
_height != other._height ||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user