Добавлен метод Equals в AbstractMap

This commit is contained in:
Данияр Аглиуллов 2022-10-31 07:48:44 +04:00
parent 087813f8fb
commit 6adfe49669
2 changed files with 28 additions and 3 deletions

View File

@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace AirBomber namespace AirBomber
{ {
internal abstract class AbstractMap internal abstract class AbstractMap : IEquatable<AbstractMap>
{ {
private IDrawningObject _drawningObject = null; private IDrawningObject _drawningObject = null;
private Bitmap? _staticBitMap; private Bitmap? _staticBitMap;
@ -174,5 +174,32 @@ namespace AirBomber
protected abstract void GenerateMap(); protected abstract void GenerateMap();
protected abstract void DrawRoadPart(Graphics g, int i, int j); protected abstract void DrawRoadPart(Graphics g, int i, int j);
protected abstract void DrawBarrierPart(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;
}
} }
} }

View File

@ -17,8 +17,6 @@ namespace AirBomber
{ {
// To customize application configuration such as set high DPI settings or default font, // To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration. // see https://aka.ms/applicationconfiguration.
var cmp = new AirplaneCompareByType();
cmp.Compare(null, null);
ApplicationConfiguration.Initialize(); ApplicationConfiguration.Initialize();
var services = new ServiceCollection(); var services = new ServiceCollection();
ConfigureServices(services); ConfigureServices(services);