Готовая восьмая лабораторная работа.

This commit is contained in:
Anastasia 2022-12-22 21:58:41 +04:00
parent 7457b34836
commit 590b2985a6
5 changed files with 17 additions and 13 deletions

View File

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

View File

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

View File

@ -76,6 +76,8 @@ namespace AirplaneWithRadar
return false;
}
}
else if (airplane is EntityAirplaneWithRadar || otherAirplaneAirplane is EntityAirplaneWithRadar) return false;
return true;
}
}

View File

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

View File

@ -152,6 +152,6 @@ namespace AirplaneWithRadar
return;
}
_places.Sort(comparer);
}
}
}
}