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);