BoatCompareByType full
This commit is contained in:
parent
20b507a35f
commit
d48d24198b
@ -6,7 +6,52 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Catamaran
|
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,6 +14,7 @@ namespace Catamaran
|
|||||||
{
|
{
|
||||||
_catamaran = catamaran;
|
_catamaran = catamaran;
|
||||||
}
|
}
|
||||||
|
public DrawingBoat GetBoat => _catamaran;
|
||||||
public float Step => _catamaran?.Catamaran?.Step ?? 0;
|
public float Step => _catamaran?.Catamaran?.Step ?? 0;
|
||||||
public (float Left, float Right, float Top, float Bottom)
|
public (float Left, float Right, float Top, float Bottom)
|
||||||
GetCurrentPosition()
|
GetCurrentPosition()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user