diff --git a/GasolineTanker/GasolineTanker/DrawingObjectGasolineTanker.cs b/GasolineTanker/GasolineTanker/DrawingObjectGasolineTanker.cs index 16f50af..9c650c3 100644 --- a/GasolineTanker/GasolineTanker/DrawingObjectGasolineTanker.cs +++ b/GasolineTanker/GasolineTanker/DrawingObjectGasolineTanker.cs @@ -38,5 +38,32 @@ namespace GasolineTanker } public string GetInfo() => _gasolineTanker?.GetDataForSave(); public static IDrawingObject Create(string data) => new DrawingObjectGasolineTanker(data.CreateDrawingGasolineTanker()); + + public bool Equals(IDrawingObject? other) + { + if (other is not DrawingObjectGasolineTanker otherGasolineTanker) + { + return false; + } + var entity = ; + var otherEntity = otherGasolineTanker.; + if (entity.GetType() != otherEntity.GetType() || + entity.Speed != otherEntity.Speed || + entity.Weight != otherEntity.Weight || + entity.BodyColor != otherEntity.BodyColor) + { + return false; + } + if (entity is EntityImprovedGasolineTanker entityImprovedGasolineTanker && + otherEntity is EntityImprovedGasolineTanker otherEntityWarmlyShip && ( + entityImprovedGasolineTanker.BodyColor != otherEntityWarmlyShip.BodyColor || + entityImprovedGasolineTanker.DopColor != otherEntityWarmlyShip.DopColor || + entityImprovedGasolineTanker.BodyKit != otherEntityWarmlyShip.BodyKit)) + { + return false; + } + return true; + } } } +} diff --git a/GasolineTanker/GasolineTanker/IDrawingObject.cs b/GasolineTanker/GasolineTanker/IDrawingObject.cs index 8697e99..4215fa0 100644 --- a/GasolineTanker/GasolineTanker/IDrawingObject.cs +++ b/GasolineTanker/GasolineTanker/IDrawingObject.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace GasolineTanker { - internal interface IDrawingObject + internal interface IDrawingObject : IEquatable { public float Step { get; } void SetObject(int x, int y, int width, int height);