Presnyakova V.V Lab_8 #17
@ -6,7 +6,52 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Catamaran
|
||||
{
|
||||
internal class BoatCompareByType
|
||||
internal class BoatCompareByType : IComparer<IDrawingObject>
|
||||
{
|
||||
public int Compare(IDrawingObject x, IDrawingObject y)
|
||||
{
|
||||
if (x == null && y == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (x == null && y != null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (x != null && y == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
var xBoat = x as DrawingObjectBoat;
|
||||
var yBoat = y as DrawingObjectBoat;
|
||||
if (xBoat == null && yBoat == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (xBoat == null && yBoat != null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (xBoat != null && yBoat == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (xBoat.GetBoat.GetType().Name != yBoat.GetBoat.GetType().Name)
|
||||
{
|
||||
if (xBoat.GetBoat.GetType().Name == "DrawingBoat")
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
var speedCompare =
|
||||
xBoat.GetBoat.Boat.Speed.CompareTo(yBoat.GetBoat.Boat.Speed);
|
||||
if (speedCompare != 0)
|
||||
{
|
||||
return speedCompare;
|
||||
}
|
||||
return xBoat.GetBoat.Boat.Weight.CompareTo(yBoat.GetBoat.Boat.Weight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,9 +14,10 @@ namespace Catamaran
|
||||
{
|
||||
_catamaran = catamaran;
|
||||
}
|
||||
public DrawingBoat GetBoat => _catamaran;
|
||||
public float Step => _catamaran?.Catamaran?.Step ?? 0;
|
||||
public (float Left, float Right, float Top, float Bottom)
|
||||
GetCurrentPosition()
|
||||
GetCurrentPosition()
|
||||
{
|
||||
return _catamaran?.GetCurrentPosition() ?? default;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user