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;