Сравнение объектов
This commit is contained in:
parent
5ec3ff18fb
commit
e3ab4bf429
@ -47,25 +47,25 @@ namespace Bus
|
||||
return false;
|
||||
}
|
||||
var otherBus = other as DrawingObjectBus;
|
||||
if (otherBus == null)
|
||||
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;
|
||||
}
|
||||
var bus = _bus.Bus;
|
||||
var otherBusBus = otherBus._bus.Bus;
|
||||
if (bus.Speed != otherBusBus.Speed)
|
||||
|
||||
if (entity is EntitySportBus entitySportBus &&
|
||||
otherEntity is EntitySportBus otherEntitySportBus && (
|
||||
entitySportBus.Wing != otherEntitySportBus.Wing ||
|
||||
entitySportBus.DopColor != otherEntitySportBus.DopColor ||
|
||||
entitySportBus.Sportline != otherEntitySportBus.Sportline))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (bus.Weight != otherBusBus.Weight)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (bus.BodyColor != otherBusBus.BodyColor)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// TODO доделать проверки в случае продвинутого объекта
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
namespace Bus
|
||||
{
|
||||
internal class MapWithSetDoubleDeckerBusGeneric<T, U>
|
||||
where T : class, IDrawingObject
|
||||
where T : class, IDrawingObject, IEquatable<T>
|
||||
where U : AbstractMap
|
||||
{
|
||||
private readonly int _pictureWidth;
|
||||
|
@ -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;
|
||||
@ -33,18 +33,15 @@ namespace Bus
|
||||
|
||||
public int Insert(T bus, int position)
|
||||
{
|
||||
if (position > _maxCount && position < 0)
|
||||
|
||||
if (_places.Contains(bus))
|
||||
throw new ArgumentException($"Объект {bus} уже есть в наборе");
|
||||
if (Count == _maxCount)
|
||||
throw new StorageOverflowException(_maxCount);
|
||||
if (!isCorrectPosition(position))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (_places.Contains(bus))
|
||||
{
|
||||
throw new ArgumentException($"Объект {bus} уже есть в наборе");
|
||||
}
|
||||
if (Count == _maxCount)
|
||||
{
|
||||
throw new StorageOverflowException(_maxCount);
|
||||
}
|
||||
_places.Insert(position, bus);
|
||||
return position;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user