final step

This commit is contained in:
Калышев Ян 2022-12-03 20:22:50 +04:00
parent 090d961ce9
commit 5526cd9bc4
2 changed files with 41 additions and 17 deletions

View File

@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace PIbd_22_Kalyshev_Y_V_MotorBoat_Base
{
internal abstract class AbstractMap
internal abstract class AbstractMap : IEquatable<AbstractMap>
{
private IDrawningObject _drawningObject = null;
protected int[,] _map = null;
@ -131,5 +131,45 @@ namespace PIbd_22_Kalyshev_Y_V_MotorBoat_Base
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;
}
var otherMap = other as AbstractMap;
if (otherMap == null)
{
return false;
}
if (_width != otherMap._width)
{
return false;
}
if (_height != otherMap._height)
{
return false;
}
if (_size_x != otherMap._size_x)
{
return false;
}
if (_size_y != otherMap._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] != otherMap._map[i, j])
{
return false;
}
}
}
return true;
}
}
}

View File

@ -41,22 +41,6 @@ namespace PIbd_22_Kalyshev_Y_V_MotorBoat_Base
{
return colorCompare;
}
if (xBoat.GetBoat.GetType().Name != yBoat.GetBoat.GetType().Name)
{
if (xBoat.GetBoat.GetType().Name == "DrawningBoat")
{
return -1;
}
return 1;
}
if (xBoat.GetBoat.Boat is EntitySpeedboat xSpeedBoat && xBoat.GetBoat.Boat is EntitySpeedboat ySpeedBoat)
{
var colorAdvCompare = xSpeedBoat.DopColor.Name.CompareTo(ySpeedBoat.DopColor.Name);
if (colorAdvCompare != 0)
{
return colorAdvCompare;
}
}
var speedCompare = xBoat.GetBoat.Boat.Speed.CompareTo(yBoat.GetBoat.Boat.Speed);
if (speedCompare != 0)
{