From d628bda63b101e4506e4965406c1306b34a39a8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B0=D1=88=D0=B8=D0=BD=20=D0=9C=D0=B0=D0=BA=D1=81?= =?UTF-8?q?=D0=B8=D0=BC?= Date: Tue, 29 Nov 2022 11:11:20 +0400 Subject: [PATCH] 5 min --- .../DrawingObjectGasolineTanker.cs | 27 +++++++++++++++++++ .../GasolineTanker/IDrawingObject.cs | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) 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);