diff --git a/Airbus/Airbus/DrawningObjectPlane.cs b/Airbus/Airbus/DrawningObjectPlane.cs index 1d9bffd..1d57aec 100644 --- a/Airbus/Airbus/DrawningObjectPlane.cs +++ b/Airbus/Airbus/DrawningObjectPlane.cs @@ -75,7 +75,7 @@ namespace Airbus return false; } - if(plane.CorpusColor != otherPlanePlane.CorpusColor) + if (plane.CorpusColor != otherPlanePlane.CorpusColor) { return false; } diff --git a/Airbus/Airbus/PlaneCompareByColor.cs b/Airbus/Airbus/PlaneCompareByColor.cs index 77538ef..92295b6 100644 --- a/Airbus/Airbus/PlaneCompareByColor.cs +++ b/Airbus/Airbus/PlaneCompareByColor.cs @@ -43,26 +43,36 @@ namespace Airbus return 1; } - if(xPlane.GetPlane.Airbus.Speed != yPlane.GetPlane.Airbus.Speed) - { - return 1; - } - - if (xPlane.GetPlane.Airbus.Weight != yPlane.GetPlane.Airbus.Weight) - { - return 1; - } - var xEntity = xPlane.GetPlane.Airbus; var yEntity = yPlane.GetPlane.Airbus; - var colorCompare = xEntity.CorpusColor.Name.CompareTo(yEntity.CorpusColor.Name); + var colorCompare = xEntity.CorpusColor.ToArgb().CompareTo(yEntity.CorpusColor.ToArgb()); - if (colorCompare != 0 || xEntity is not EntitySuperAirbus xEntityAirbus || yEntity is not EntitySuperAirbus yEntityAirbus) + int i = xEntity.CorpusColor.ToArgb(); + int j = yEntity.CorpusColor.ToArgb(); + + if (colorCompare != 0) { return colorCompare; } - return xEntityAirbus.AddColor.Name.CompareTo(yEntityAirbus.AddColor.Name); + if (xEntity is EntitySuperAirbus xEntityAirbus && yEntity is EntitySuperAirbus yEntityAirbus) + { + var addColorCompare = xEntityAirbus.AddColor.ToArgb().CompareTo(yEntityAirbus.AddColor.ToArgb()); + + if(addColorCompare != 0) + { + return addColorCompare; + } + } + + var speedCompare = xPlane.GetPlane.Airbus.Speed.CompareTo(yPlane.GetPlane.Airbus.Speed); + + if (speedCompare != 0) + { + return speedCompare; + } + + return xPlane.GetPlane.Airbus.Weight.CompareTo(yPlane.GetPlane.Airbus.Weight); } } }