From acba9f20715565754d5723588c72f10b59d5cd16 Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Sat, 3 Dec 2022 15:22:28 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B5=D0=B1=D0=BE=D0=BB=D1=8C=D1=88?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=B4=D0=BE=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=BA?= =?UTF-8?q?=D0=B8=208-=D0=B9=20=D0=BB=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82?= =?UTF-8?q?=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 | 9 +++++++-- Airbus/Airbus/PlaneCompareByColor.cs | 4 ++-- Airbus/Airbus/SaveData.txt | 2 +- Airbus/Airbus/SetPlanesGeneric.cs | 16 ++++++---------- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/Airbus/Airbus/DrawningObjectPlane.cs b/Airbus/Airbus/DrawningObjectPlane.cs index 0eead77..1d9bffd 100644 --- a/Airbus/Airbus/DrawningObjectPlane.cs +++ b/Airbus/Airbus/DrawningObjectPlane.cs @@ -80,7 +80,12 @@ namespace Airbus return false; } - if(plane is EntitySuperAirbus entitySuperAirbus && otherPlanePlane is EntitySuperAirbus otherEntitySuperAirbus) + if(plane.GetType().Name != otherPlanePlane.GetType().Name) + { + return false; + } + + if (plane is EntitySuperAirbus entitySuperAirbus && otherPlanePlane is EntitySuperAirbus otherEntitySuperAirbus) { if(entitySuperAirbus.AddEngine != otherEntitySuperAirbus.AddEngine) { @@ -92,7 +97,7 @@ namespace Airbus return false; } - if(entitySuperAirbus.AddColor.ToArgb() != otherEntitySuperAirbus.AddColor.ToArgb()) + if(entitySuperAirbus.AddColor.Name != otherEntitySuperAirbus.AddColor.Name) { return false; } diff --git a/Airbus/Airbus/PlaneCompareByColor.cs b/Airbus/Airbus/PlaneCompareByColor.cs index a32410d..388d7c3 100644 --- a/Airbus/Airbus/PlaneCompareByColor.cs +++ b/Airbus/Airbus/PlaneCompareByColor.cs @@ -45,14 +45,14 @@ namespace Airbus var xEntity = xPlane.GetPlane.Airbus; var yEntity = yPlane.GetPlane.Airbus; - var colorCompare = xEntity.CorpusColor.ToArgb().CompareTo(yEntity.CorpusColor.ToArgb()); + var colorCompare = xEntity.CorpusColor.Name.CompareTo(yEntity.CorpusColor.Name); if (colorCompare != 0 || xEntity is not EntitySuperAirbus xEntityAirbus || yEntity is not EntitySuperAirbus yEntityAirbus) { return colorCompare; } - return xEntityAirbus.AddColor.ToArgb().CompareTo(yEntityAirbus.AddColor.ToArgb()); + return xEntityAirbus.AddColor.Name.CompareTo(yEntityAirbus.AddColor.Name); } } } diff --git a/Airbus/Airbus/SaveData.txt b/Airbus/Airbus/SaveData.txt index c96b589..bcb8f5d 100644 --- a/Airbus/Airbus/SaveData.txt +++ b/Airbus/Airbus/SaveData.txt @@ -1,2 +1,2 @@ MapsCollection -123|StarWarsMap|1000:750:Red;1000:750:DeepPink:Control:False:False; +345|DesertStormMap|1000:750:Black:Yellow:False:True;1010:760:Yellow;1005:755:Lime; diff --git a/Airbus/Airbus/SetPlanesGeneric.cs b/Airbus/Airbus/SetPlanesGeneric.cs index 301ab42..f5db532 100644 --- a/Airbus/Airbus/SetPlanesGeneric.cs +++ b/Airbus/Airbus/SetPlanesGeneric.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Numerics; using System.Reflection.PortableExecutable; using System.Text; using System.Threading.Tasks; @@ -29,11 +30,6 @@ namespace Airbus //добавление объекта в набор public int Insert(T plane) { - if (_places.Contains(plane)) - { - throw new ArgumentException($"Объект {plane} уже есть в данном наборе"); - } - if (Count == _maxCount) { throw new StorageOverflowException(_maxCount); @@ -47,16 +43,16 @@ namespace Airbus //добавление объекта в набор на конкретную позицию public int Insert(T plane, int position) { - if (position > _maxCount && position < 0) - { - return -1; - } - if (_places.Contains(plane)) { throw new ArgumentException($"Объект {plane} уже есть в наборе"); } + if (position > _maxCount && position < 0) + { + return -1; + } + _places.Insert(position, plane); return position;