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