логикa сравнения
This commit is contained in:
parent
68170b1023
commit
9619d8ea89
@ -11,8 +11,44 @@ namespace Catamaran
|
||||
{
|
||||
public int Compare(IDrawingObject x, IDrawingObject y)
|
||||
{
|
||||
// TODO реализовать логику сравнения
|
||||
throw new NotImplementedException();
|
||||
// реализовать логику сравнения
|
||||
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;
|
||||
}
|
||||
int colorCompare = string.Compare(xBoat.GetBoat.Catamaran.BodyColor.Name, yBoat.GetBoat.Catamaran.BodyColor.Name);
|
||||
if (colorCompare != 0)
|
||||
{
|
||||
return colorCompare;
|
||||
}
|
||||
var speedCompare = xBoat.GetBoat.Catamaran.Speed.CompareTo(yBoat.GetBoat.Catamaran.Speed);
|
||||
if (speedCompare != 0)
|
||||
{
|
||||
return speedCompare;
|
||||
}
|
||||
return xBoat.GetBoat.Catamaran.Weight.CompareTo(yBoat.GetBoat.Catamaran.Weight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user