From 519ba5ef7a008d25aff7baf9915c29e4cd899387 Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Sat, 3 Dec 2022 20:56:25 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9C=D0=B5=D0=BB=D0=BA=D0=B8=D0=B5=20=D0=BF?= =?UTF-8?q?=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=208-=D0=B9=20=D0=BB=D0=B0=D0=B1?= =?UTF-8?q?=D0=BE=D1=80=D0=B0=D1=82=D0=BE=D1=80=D0=BD=D0=BE=D0=B9.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Airbus/Airbus/DrawningObjectPlane.cs | 2 +- Airbus/Airbus/PlaneCompareByColor.cs | 36 ++++++++++++++++++---------- 2 files changed, 24 insertions(+), 14 deletions(-) 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); } } }