diff --git a/AirBomber/AirBomber/DrawningObjectBomber.cs b/AirBomber/AirBomber/DrawningObjectBomber.cs index b49ee71..e1d1679 100644 --- a/AirBomber/AirBomber/DrawningObjectBomber.cs +++ b/AirBomber/AirBomber/DrawningObjectBomber.cs @@ -40,5 +40,36 @@ namespace AirBomber public string GetInfo() => _airBomber?.GetDataForSave(); public static IDrawningObject Create(string data) => new DrawningObjectBomber(data.CreateDrawningAirBomber()); + + public bool Equals(IDrawningObject? other) + { + if (other == null) + { + return false; + } + var otherBomber = other as DrawningObjectBomber; + if (otherBomber == null) + { + return false; + } + var airBomber = _airBomber.AirBomber; + var otherBomberBomber = otherBomber._airBomber.AirBomber; + if (airBomber.Speed != otherBomberBomber.Speed) + { + return false; + } + if (airBomber.Weight != otherBomberBomber.Weight) + { + return false; + } + if (airBomber.BodyColor != otherBomberBomber.BodyColor) + { + return false; + } + + //TODO + + return true; + } } } diff --git a/AirBomber/AirBomber/IDrawningObject.cs b/AirBomber/AirBomber/IDrawningObject.cs index a32cb67..222f745 100644 --- a/AirBomber/AirBomber/IDrawningObject.cs +++ b/AirBomber/AirBomber/IDrawningObject.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace AirBomber { - internal interface IDrawningObject + internal interface IDrawningObject : IEquatable { public float Step { get; } diff --git a/AirBomber/AirBomber/MapWithSetAirBomberGeneric.cs b/AirBomber/AirBomber/MapWithSetAirBomberGeneric.cs index 8e9e2ef..33bd31d 100644 --- a/AirBomber/AirBomber/MapWithSetAirBomberGeneric.cs +++ b/AirBomber/AirBomber/MapWithSetAirBomberGeneric.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; namespace AirBomber { internal class MapWithSetAirBomberGeneric - where T : class, IDrawningObject + where T : class, IDrawningObject, IEquatable where U : AbstractMap { private readonly int _pictureWidth; diff --git a/AirBomber/AirBomber/SetAirBomberGeneric.cs b/AirBomber/AirBomber/SetAirBomberGeneric.cs index 4cac74d..283664e 100644 --- a/AirBomber/AirBomber/SetAirBomberGeneric.cs +++ b/AirBomber/AirBomber/SetAirBomberGeneric.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; namespace AirBomber { internal class SetAirBomberGeneric - where T : class + where T : class, IEquatable { private readonly List _places; @@ -28,6 +28,7 @@ namespace AirBomber public int Insert(T airBomber, int position) { + //TODO проверка на уникальность if (_places.Count >= _maxCount) { throw new StorageOverflowException(_maxCount);