Nugaev D.N. LabWork08 #11

Closed
Damir_Nugaev_ISEbd-22 wants to merge 4 commits from Lab_work08 into Lab_work07
Showing only changes of commit 0c0647c54d - Show all commits

View File

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace Bus
{
internal abstract class AbstractMap
internal abstract class AbstractMap : IEquatable<AbstractMap>
{
private IDrawingObject _drawingObject = null;
protected int[,] _map = null;
@ -164,5 +164,30 @@ namespace Bus
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 (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;
}
}
}