Готовая восьмая лабораторная работа.
This commit is contained in:
parent
7457b34836
commit
590b2985a6
@ -8,7 +8,7 @@ namespace AirplaneWithRadar
|
||||
{
|
||||
internal class AirplaneCompareByColor : IComparer<IDrawingObject>
|
||||
{
|
||||
public int Compare(IDrawingObject x, IDrawingObject y)
|
||||
public int Compare(IDrawingObject? x, IDrawingObject? y)
|
||||
{
|
||||
if (x == null && y == null)
|
||||
{
|
||||
@ -36,19 +36,17 @@ namespace AirplaneWithRadar
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
string xAirplaneColor = xAirplane.GetAirplane.Airplane.BodyColor.Name;
|
||||
string yAirplaneColor = yAirplane.GetAirplane.Airplane.BodyColor.Name;
|
||||
if (xAirplaneColor != yAirplaneColor)
|
||||
var baseColorCompare = xAirplane.GetAirplane.Airplane.BodyColor.ToString().CompareTo(yAirplane.GetAirplane.Airplane.BodyColor.ToString());
|
||||
if (baseColorCompare != 0)
|
||||
{
|
||||
return xAirplaneColor.CompareTo(yAirplane);
|
||||
return baseColorCompare;
|
||||
}
|
||||
if (xAirplane.GetAirplane.Airplane is EntityAirplaneWithRadar xAirpl && yAirplane.GetAirplane.Airplane is EntityAirplaneWithRadar yAirpl)
|
||||
{
|
||||
string xAirplaneDopColor = xAirpl.DopColor.Name;
|
||||
string yAirplaneDopColor = yAirpl.DopColor.Name;
|
||||
if (xAirplaneDopColor != yAirplaneDopColor)
|
||||
var dopColorCompare = xAirpl.DopColor.ToString().CompareTo(yAirpl.DopColor.ToString());
|
||||
if (dopColorCompare != 0)
|
||||
{
|
||||
return xAirplaneDopColor.CompareTo(yAirplaneDopColor);
|
||||
return dopColorCompare;
|
||||
}
|
||||
}
|
||||
var speedCompare = xAirplane.GetAirplane.Airplane.Speed.CompareTo(yAirplane.GetAirplane.Airplane.Speed);
|
||||
|
@ -40,9 +40,9 @@ namespace AirplaneWithRadar
|
||||
{
|
||||
if (xAirplane.GetAirplane.GetType().Name == "DrawingAirplane")
|
||||
{
|
||||
return 1;
|
||||
return -1;
|
||||
}
|
||||
return -1;
|
||||
return 1;
|
||||
}
|
||||
var speedCompare = xAirplane.GetAirplane.Airplane.Speed.CompareTo(yAirplane.GetAirplane.Airplane.Speed);
|
||||
if (speedCompare != 0)
|
||||
|
@ -76,6 +76,8 @@ namespace AirplaneWithRadar
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (airplane is EntityAirplaneWithRadar || otherAirplaneAirplane is EntityAirplaneWithRadar) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,11 @@ namespace AirplaneWithRadar
|
||||
SetData();
|
||||
Draw();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ïåðåìåùåíèå
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ButtonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
string name = ((Button)sender)?.Name ?? string.Empty;
|
||||
|
@ -152,6 +152,6 @@ namespace AirplaneWithRadar
|
||||
return;
|
||||
}
|
||||
_places.Sort(comparer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user