Nugaev D.N Lab_work08 #9

Closed
Damir_Nugaev_ISEbd-22 wants to merge 1 commits from Lab_work08 into Lab_work07
4 changed files with 29 additions and 4 deletions
Showing only changes of commit 7e06625cc9 - Show all commits

View File

@ -39,6 +39,31 @@ namespace Bus
public string GetInfo() => _bus?.GetDataForSave();
public static IDrawingObject Create(string data) => new DrawingObjectBus(data.CreateDrawingBus());
public bool Equals(IDrawingObject? other)
{
if (other is not DrawingObjectBus otherBus)
{
return false;
}
var entity = _bus.Bus;
var otherEntity = otherBus._bus.Bus;
if (entity.GetType() != otherEntity.GetType() ||
entity.Speed != otherEntity.Speed ||
entity.Weight != otherEntity.Weight ||
entity.BodyColor != otherEntity.BodyColor)
{
return false;
}
if (entity is EntitySportBus entitySportBus &&
otherEntity is EntitySportBus otherEntitySportBus && (
entitySportBus.Wing != otherEntitySportBus.Wing ||
entitySportBus.DopColor != otherEntitySportBus.DopColor ||
entitySportBus.Sportline != otherEntitySportBus.Sportline))
{
return false;
}
return true;
}
}
}

View File

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace Bus
{
internal interface IDrawingObject
internal interface IDrawingObject : IEquatable<IDrawingObject>
{
public float Step { get; }
void SetObject(int x, int y, int width, int height);

View File

@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace Bus
{
internal class MapWithSetDoubleDeckerBusGeneric<T, U>
where T : class, IDrawingObject
where T : class, IEquatable<T>, IDrawingObject
where U : AbstractMap
{
private readonly int _pictureWidth;

View File

@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace Bus
{
internal class SetDoubleDeckerBusGeneric<T>
where T : class
where T : class, IEquatable<T>
{
private readonly List<T> _places;
public int Count => _places.Count;