Сравнение объектов
This commit is contained in:
parent
5327e9044f
commit
7e06625cc9
@ -39,6 +39,31 @@ namespace Bus
|
||||
public string GetInfo() => _bus?.GetDataForSave();
|
||||
|
||||
public static IDrawingObject Create(string data) => new DrawingObjectBus(data.CreateDrawingBus());
|
||||
|
||||
|
||||
public bool Equals(IDrawingObject? other)
|
||||
{
|
||||
if (other is not DrawingObjectBus otherBus)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var entity = _bus.Bus;
|
||||
var otherEntity = otherBus._bus.Bus;
|
||||
if (entity.GetType() != otherEntity.GetType() ||
|
||||
entity.Speed != otherEntity.Speed ||
|
||||
entity.Weight != otherEntity.Weight ||
|
||||
entity.BodyColor != otherEntity.BodyColor)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (entity is EntitySportBus entitySportBus &&
|
||||
otherEntity is EntitySportBus otherEntitySportBus && (
|
||||
entitySportBus.Wing != otherEntitySportBus.Wing ||
|
||||
entitySportBus.DopColor != otherEntitySportBus.DopColor ||
|
||||
entitySportBus.Sportline != otherEntitySportBus.Sportline))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Bus
|
||||
{
|
||||
internal interface IDrawingObject
|
||||
internal interface IDrawingObject : IEquatable<IDrawingObject>
|
||||
{
|
||||
public float Step { get; }
|
||||
void SetObject(int x, int y, int width, int height);
|
||||
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
namespace Bus
|
||||
{
|
||||
internal class MapWithSetDoubleDeckerBusGeneric<T, U>
|
||||
where T : class, IDrawingObject
|
||||
where T : class, IEquatable<T>, IDrawingObject
|
||||
where U : AbstractMap
|
||||
{
|
||||
private readonly int _pictureWidth;
|
||||
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
namespace Bus
|
||||
{
|
||||
internal class SetDoubleDeckerBusGeneric<T>
|
||||
where T : class
|
||||
where T : class, IEquatable<T>
|
||||
{
|
||||
private readonly List<T> _places;
|
||||
public int Count => _places.Count;
|
||||
|
Loading…
Reference in New Issue
Block a user