Presnyakova V.V Lab_8 #17

Closed
Victoria_Presnyakova wants to merge 12 commits from Lab_8 into Lab_7
2 changed files with 48 additions and 2 deletions
Showing only changes of commit d48d24198b - Show all commits

View File

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

View File

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