Morozov V.S LabWork08 #9

Closed
VoldemarProger wants to merge 3 commits from LabWork08 into LabWork07
4 changed files with 34 additions and 3 deletions
Showing only changes of commit a145a52010 - Show all commits

View File

@ -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;
}
}
}

View File

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

View File

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

View File

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