1st step
This commit is contained in:
parent
1c4c533ceb
commit
93a18dcbb5
@ -32,5 +32,56 @@ namespace PIbd_22_Kalyshev_Y_V_MotorBoat_Base
|
||||
_boat.SetPosition(x, y, width, height);
|
||||
}
|
||||
public static IDrawningObject Create(string data) => new DrawningObjectBoat(data.CreateDrawningBoat());
|
||||
|
||||
public bool Equals(IDrawningObject? other)
|
||||
{
|
||||
if (other == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var otherBoat = other as DrawningObjectBoat;
|
||||
if (otherBoat == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var boat = _boat.Boat;
|
||||
var otherBoatBoat = otherBoat._boat.Boat;
|
||||
if (boat.GetType() != otherBoatBoat.GetType())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (boat.Speed != otherBoatBoat.Speed)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (boat.Weight != otherBoatBoat.Weight)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (boat.BodyColor != otherBoatBoat.BodyColor)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (boat is EntitySpeedboat speedboat && otherBoatBoat is EntitySpeedboat otherSpeedboatSpeedboat)
|
||||
{
|
||||
if (speedboat.DopColor != otherSpeedboatSpeedboat.DopColor)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (speedboat.BodyKit != otherSpeedboatSpeedboat.BodyKit)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (speedboat.Wing != otherSpeedboatSpeedboat.Wing)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (speedboat.SportLine != otherSpeedboatSpeedboat.SportLine)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace PIbd_22_Kalyshev_Y_V_MotorBoat_Base
|
||||
{
|
||||
internal interface IDrawningObject
|
||||
internal interface IDrawningObject : IEquatable<IDrawningObject>
|
||||
{
|
||||
/// <summary>
|
||||
/// Шаг перемещения объекта
|
||||
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
namespace PIbd_22_Kalyshev_Y_V_MotorBoat_Base
|
||||
{
|
||||
internal class MapWithSetBoatsGeneric<T, U>
|
||||
where T : class, IDrawningObject
|
||||
where T : class, IDrawningObject, IEquatable<T>
|
||||
where U : AbstractMap
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -8,7 +8,7 @@ using System.Threading.Tasks;
|
||||
namespace PIbd_22_Kalyshev_Y_V_MotorBoat_Base
|
||||
{
|
||||
internal class SetBoatsGeneric<T>
|
||||
where T : class
|
||||
where T : class, IEquatable<T>
|
||||
{
|
||||
/// <summary>
|
||||
/// Список объектов, которые храним
|
||||
@ -36,6 +36,10 @@ namespace PIbd_22_Kalyshev_Y_V_MotorBoat_Base
|
||||
/// <returns></returns>
|
||||
public int Insert(T boat)
|
||||
{
|
||||
if (!_places.Contains(boat))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (_places.Count < _maxCount)
|
||||
{
|
||||
_places.Add(boat);
|
||||
|
Loading…
Reference in New Issue
Block a user