From 5ec3ff18fbb1fed16a6e670eb3f48dcacfab22b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BC=D0=B8=D1=80=20=D0=9D=D1=83=D0=B3=D0=B0?= =?UTF-8?q?=D0=B5=D0=B2?= Date: Tue, 22 Nov 2022 11:34:09 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BF=D1=80=D0=BE=D0=BC=D0=B5=D0=B6=D1=83?= =?UTF-8?q?=D1=82=D0=BE=D1=87=D0=BD=D0=B0=D1=8F=20=D1=84=D0=B8=D0=BA=D1=81?= =?UTF-8?q?=D0=B0=D1=86=D0=B8=D1=8F=201.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bus/Bus/DrawingObjectBus.cs | 30 +++++++++++++++++++++++++++++- Bus/Bus/IDrawingObject.cs | 2 +- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/Bus/Bus/DrawingObjectBus.cs b/Bus/Bus/DrawingObjectBus.cs index a3b541d..ae73512 100644 --- a/Bus/Bus/DrawingObjectBus.cs +++ b/Bus/Bus/DrawingObjectBus.cs @@ -39,6 +39,34 @@ namespace Bus public string GetInfo() => _bus?.GetDataForSave(); public static IDrawingObject Create(string data) => new DrawingObjectBus(data.CreateDrawingBus()); - + + public bool Equals(IDrawingObject? other) + { + if (other == null) + { + return false; + } + var otherBus = other as DrawingObjectBus; + if (otherBus == null) + { + return false; + } + var bus = _bus.Bus; + var otherBusBus = otherBus._bus.Bus; + if (bus.Speed != otherBusBus.Speed) + { + return false; + } + if (bus.Weight != otherBusBus.Weight) + { + return false; + } + if (bus.BodyColor != otherBusBus.BodyColor) + { + return false; + } + // TODO доделать проверки в случае продвинутого объекта + return true; + } } } diff --git a/Bus/Bus/IDrawingObject.cs b/Bus/Bus/IDrawingObject.cs index 321b39f..f41e4b4 100644 --- a/Bus/Bus/IDrawingObject.cs +++ b/Bus/Bus/IDrawingObject.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace Bus { - internal interface IDrawingObject + internal interface IDrawingObject : IEquatable { public float Step { get; } void SetObject(int x, int y, int width, int height);