Morozov V.S LabWork08 #9
@ -39,5 +39,35 @@ namespace AirPlaneWithRadar
|
||||
{
|
||||
_plain.setPosition(x, y, width, height);
|
||||
}
|
||||
|
||||
public bool Equals(IDrawingObject? other)
|
||||
{
|
||||
if (other == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var otherPlain = other as DrawingObjectPlane;
|
||||
if (otherPlain == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var plain = _plain.Plain;
|
||||
var otherPlainPlain = otherPlain._plain.Plain;
|
||||
|
||||
if (plain.Speed != otherPlainPlain.Speed)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (plain.Weight != otherPlainPlain.Weight)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (plain.BodyColor != otherPlainPlain.BodyColor)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace AirPlaneWithRadar
|
||||
{
|
||||
internal interface IDrawingObject
|
||||
internal interface IDrawingObject : IEquatable<IDrawingObject>
|
||||
{
|
||||
public float Step { get; }
|
||||
void SetObject(int x, int y, int width, int height);
|
||||
|
@ -8,7 +8,7 @@ namespace AirPlaneWithRadar
|
||||
{
|
||||
internal class MapWithSetPlainGeneric
|
||||
<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 AirPlaneWithRadar
|
||||
{
|
||||
internal class SetPlaneGeneric<T>
|
||||
where T : class
|
||||
where T : class, IEquatable<T>
|
||||
|
||||
{
|
||||
private readonly List<T> _places;
|
||||
@ -26,6 +26,7 @@ namespace AirPlaneWithRadar
|
||||
}
|
||||
public int Insert(T plain, int position)
|
||||
{
|
||||
/////
|
||||
if (_places.Count == _maxCount)
|
||||
{
|
||||
throw new StorageOverFullException(_maxCount);
|
||||
|
Loading…
Reference in New Issue
Block a user