From 13591af122c68530617f8ab6efc748a9feb54453 Mon Sep 17 00:00:00 2001 From: ArtemEmelyanov Date: Fri, 9 Dec 2022 12:17:27 +0400 Subject: [PATCH 1/4] =?UTF-8?q?=D0=A1=D1=80=D0=B0=D0=B2=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BE=D0=B1=D1=8A=D0=B5=D0=BA=D1=82=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Airbus/Airbus/DrawningObjectPlane.cs | 48 ++++++++++++++++++++++++ Airbus/Airbus/IDrawningObject.cs | 2 +- Airbus/Airbus/MapWithSetPlanesGeneric.cs | 2 +- Airbus/Airbus/SetPlanesGeneric.cs | 6 ++- 4 files changed, 55 insertions(+), 3 deletions(-) diff --git a/Airbus/Airbus/DrawningObjectPlane.cs b/Airbus/Airbus/DrawningObjectPlane.cs index 3c784e9..e6ea06f 100644 --- a/Airbus/Airbus/DrawningObjectPlane.cs +++ b/Airbus/Airbus/DrawningObjectPlane.cs @@ -33,5 +33,53 @@ namespace Airbus } public string GetInfo() => _plane?.GetDataForSave(); public static IDrawningObject Create(string data) => new DrawningObjectPlane(data.CreateDrawningPlane()); + + public bool Equals(IDrawningObject? other) + { + if (other == null) + { + return false; + } + var otherPlane = other as DrawningObjectPlane; + if (otherPlane == null) + { + return false; + } + var plane = _plane.Plane; + var otherPlanePlane = otherPlane._plane.Plane; + if (plane.Speed != otherPlanePlane.Speed) + { + return false; + } + if (plane.Weight != otherPlanePlane.Weight) + { + return false; + } + if (plane.BodyColor != otherPlanePlane.BodyColor) + { + return false; + } + + if (plane is EntityAirbus airbus && otherPlanePlane is EntityAirbus otherAirbus) + { + if (airbus.DopColor != otherAirbus.DopColor) + { + return false; + } + if (airbus.BodyKit != otherAirbus.BodyKit) + { + return false; + } + if (airbus.Wing != otherAirbus.BodyKit) + { + return false; + } + if (airbus.SportLine != otherAirbus.SportLine) + { + return false; + } + } + return true; + } } } diff --git a/Airbus/Airbus/IDrawningObject.cs b/Airbus/Airbus/IDrawningObject.cs index bb65f5b..177e616 100644 --- a/Airbus/Airbus/IDrawningObject.cs +++ b/Airbus/Airbus/IDrawningObject.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace Airbus { - internal interface IDrawningObject + internal interface IDrawningObject : IEquatable { /// /// Шаг перемещения объекта diff --git a/Airbus/Airbus/MapWithSetPlanesGeneric.cs b/Airbus/Airbus/MapWithSetPlanesGeneric.cs index ebaf55b..4abb1ea 100644 --- a/Airbus/Airbus/MapWithSetPlanesGeneric.cs +++ b/Airbus/Airbus/MapWithSetPlanesGeneric.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; namespace Airbus { internal class MapWithSetPlanesGeneric - where T : class, IDrawningObject + where T : class, IDrawningObject, IEquatable where U : AbstractMap { /// diff --git a/Airbus/Airbus/SetPlanesGeneric.cs b/Airbus/Airbus/SetPlanesGeneric.cs index 4036acb..0e6a6b9 100644 --- a/Airbus/Airbus/SetPlanesGeneric.cs +++ b/Airbus/Airbus/SetPlanesGeneric.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; namespace Airbus { internal class SetPlanesGeneric - where T : class + where T : class, IEquatable { /// /// Список объектов, которые храним @@ -48,6 +48,10 @@ namespace Airbus { // TODO проверка позиции // TODO вставка по позиции + if (_places.Contains(plane)) + { + return -1; + } if (_places.Count == _maxCount) throw new StorageOverflowException(_maxCount); _places.Insert(position, plane); return position; -- 2.25.1 From 7aab615e91205a55c11e4a9d5d2ab3235bf0fbc0 Mon Sep 17 00:00:00 2001 From: ArtemEmelyanov Date: Fri, 9 Dec 2022 12:31:38 +0400 Subject: [PATCH 2/4] =?UTF-8?q?=D0=A1=D0=BE=D1=80=D1=82=D0=B8=D1=80=D0=BE?= =?UTF-8?q?=D0=B2=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Airbus/Airbus/DrawningObjectPlane.cs | 1 + .../Airbus/FormMapWithSetPlanes.Designer.cs | 54 +++++++++++++----- Airbus/Airbus/FormMapWithSetPlanes.cs | 20 +++++++ Airbus/Airbus/MapWithSetPlanesGeneric.cs | 4 ++ Airbus/Airbus/PlaneCompareByColor.cs | 16 ++++++ Airbus/Airbus/PlaneCompareByType.cs | 55 +++++++++++++++++++ Airbus/Airbus/SetPlanesGeneric.cs | 9 +++ 7 files changed, 145 insertions(+), 14 deletions(-) create mode 100644 Airbus/Airbus/PlaneCompareByColor.cs create mode 100644 Airbus/Airbus/PlaneCompareByType.cs diff --git a/Airbus/Airbus/DrawningObjectPlane.cs b/Airbus/Airbus/DrawningObjectPlane.cs index e6ea06f..ba3dab5 100644 --- a/Airbus/Airbus/DrawningObjectPlane.cs +++ b/Airbus/Airbus/DrawningObjectPlane.cs @@ -14,6 +14,7 @@ namespace Airbus _plane = plane; } public float Step => _plane?.Plane?.Step ?? 0; + public DrawningPlane GetPlane => _plane; public (float Left, float Top, float Right, float Bottom) GetCurrentPosition() { diff --git a/Airbus/Airbus/FormMapWithSetPlanes.Designer.cs b/Airbus/Airbus/FormMapWithSetPlanes.Designer.cs index 64e4f6e..c74cc66 100644 --- a/Airbus/Airbus/FormMapWithSetPlanes.Designer.cs +++ b/Airbus/Airbus/FormMapWithSetPlanes.Designer.cs @@ -51,6 +51,8 @@ this.LoadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.openFileDialog = new System.Windows.Forms.OpenFileDialog(); this.saveFileDialog = new System.Windows.Forms.SaveFileDialog(); + this.buttonSortByType = new System.Windows.Forms.Button(); + this.buttonSortByColor = new System.Windows.Forms.Button(); this.groupBox1.SuspendLayout(); this.groupBoxMaps.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit(); @@ -59,6 +61,8 @@ // // groupBox1 // + this.groupBox1.Controls.Add(this.buttonSortByColor); + this.groupBox1.Controls.Add(this.buttonSortByType); this.groupBox1.Controls.Add(this.groupBoxMaps); this.groupBox1.Controls.Add(this.buttonLeft); this.groupBox1.Controls.Add(this.buttonRight); @@ -72,7 +76,7 @@ this.groupBox1.Dock = System.Windows.Forms.DockStyle.Right; this.groupBox1.Location = new System.Drawing.Point(657, 24); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(200, 616); + this.groupBox1.Size = new System.Drawing.Size(200, 674); this.groupBox1.TabIndex = 0; this.groupBox1.TabStop = false; this.groupBox1.Text = "Инструменты"; @@ -143,7 +147,7 @@ // this.buttonLeft.BackgroundImage = global::Airbus.Properties.Resources.arrowLeft; this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonLeft.Location = new System.Drawing.Point(56, 572); + this.buttonLeft.Location = new System.Drawing.Point(56, 634); this.buttonLeft.Name = "buttonLeft"; this.buttonLeft.Size = new System.Drawing.Size(30, 30); this.buttonLeft.TabIndex = 9; @@ -154,7 +158,7 @@ // this.buttonRight.BackgroundImage = global::Airbus.Properties.Resources.arrowRight; this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonRight.Location = new System.Drawing.Point(128, 572); + this.buttonRight.Location = new System.Drawing.Point(128, 634); this.buttonRight.Name = "buttonRight"; this.buttonRight.Size = new System.Drawing.Size(30, 30); this.buttonRight.TabIndex = 8; @@ -165,7 +169,7 @@ // this.buttonDown.BackgroundImage = global::Airbus.Properties.Resources.arrowDown; this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonDown.Location = new System.Drawing.Point(92, 572); + this.buttonDown.Location = new System.Drawing.Point(92, 634); this.buttonDown.Name = "buttonDown"; this.buttonDown.Size = new System.Drawing.Size(30, 30); this.buttonDown.TabIndex = 7; @@ -176,7 +180,7 @@ // this.buttonUp.BackgroundImage = global::Airbus.Properties.Resources.arrowUp; this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; - this.buttonUp.Location = new System.Drawing.Point(92, 536); + this.buttonUp.Location = new System.Drawing.Point(92, 598); this.buttonUp.Name = "buttonUp"; this.buttonUp.Size = new System.Drawing.Size(30, 30); this.buttonUp.TabIndex = 6; @@ -185,7 +189,7 @@ // // buttonShowOnMap // - this.buttonShowOnMap.Location = new System.Drawing.Point(17, 499); + this.buttonShowOnMap.Location = new System.Drawing.Point(17, 561); this.buttonShowOnMap.Name = "buttonShowOnMap"; this.buttonShowOnMap.Size = new System.Drawing.Size(171, 31); this.buttonShowOnMap.TabIndex = 5; @@ -195,7 +199,7 @@ // // buttonShowStorage // - this.buttonShowStorage.Location = new System.Drawing.Point(17, 459); + this.buttonShowStorage.Location = new System.Drawing.Point(17, 521); this.buttonShowStorage.Name = "buttonShowStorage"; this.buttonShowStorage.Size = new System.Drawing.Size(171, 34); this.buttonShowStorage.TabIndex = 4; @@ -205,7 +209,7 @@ // // buttonRemovePlane // - this.buttonRemovePlane.Location = new System.Drawing.Point(17, 400); + this.buttonRemovePlane.Location = new System.Drawing.Point(17, 462); this.buttonRemovePlane.Name = "buttonRemovePlane"; this.buttonRemovePlane.Size = new System.Drawing.Size(171, 31); this.buttonRemovePlane.TabIndex = 3; @@ -215,7 +219,7 @@ // // maskedTextBoxPosition // - this.maskedTextBoxPosition.Location = new System.Drawing.Point(17, 371); + this.maskedTextBoxPosition.Location = new System.Drawing.Point(17, 433); this.maskedTextBoxPosition.Mask = "00"; this.maskedTextBoxPosition.Name = "maskedTextBoxPosition"; this.maskedTextBoxPosition.Size = new System.Drawing.Size(171, 23); @@ -223,7 +227,7 @@ // // buttonAddPlane // - this.buttonAddPlane.Location = new System.Drawing.Point(17, 315); + this.buttonAddPlane.Location = new System.Drawing.Point(17, 377); this.buttonAddPlane.Name = "buttonAddPlane"; this.buttonAddPlane.Size = new System.Drawing.Size(171, 31); this.buttonAddPlane.TabIndex = 1; @@ -236,7 +240,7 @@ this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill; this.pictureBox.Location = new System.Drawing.Point(0, 24); this.pictureBox.Name = "pictureBox"; - this.pictureBox.Size = new System.Drawing.Size(657, 616); + this.pictureBox.Size = new System.Drawing.Size(657, 674); this.pictureBox.TabIndex = 0; this.pictureBox.TabStop = false; // @@ -262,14 +266,14 @@ // SaveToolStripMenuItem // this.SaveToolStripMenuItem.Name = "SaveToolStripMenuItem"; - this.SaveToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.SaveToolStripMenuItem.Size = new System.Drawing.Size(141, 22); this.SaveToolStripMenuItem.Text = "Сохранение"; this.SaveToolStripMenuItem.Click += new System.EventHandler(this.SaveToolStripMenuItem_Click); // // LoadToolStripMenuItem // this.LoadToolStripMenuItem.Name = "LoadToolStripMenuItem"; - this.LoadToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.LoadToolStripMenuItem.Size = new System.Drawing.Size(141, 22); this.LoadToolStripMenuItem.Text = "Загрузка"; this.LoadToolStripMenuItem.Click += new System.EventHandler(this.LoadToolStripMenuItem_Click); // @@ -281,11 +285,31 @@ // this.saveFileDialog.Filter = "«txt file | *.txt"; // + // buttonSortByType + // + this.buttonSortByType.Location = new System.Drawing.Point(17, 291); + this.buttonSortByType.Name = "buttonSortByType"; + this.buttonSortByType.Size = new System.Drawing.Size(171, 26); + this.buttonSortByType.TabIndex = 11; + this.buttonSortByType.Text = "Сортировать по типу"; + this.buttonSortByType.UseVisualStyleBackColor = true; + this.buttonSortByType.Click += new System.EventHandler(this.buttonSortByType_Click); + // + // buttonSortByColor + // + this.buttonSortByColor.Location = new System.Drawing.Point(17, 323); + this.buttonSortByColor.Name = "buttonSortByColor"; + this.buttonSortByColor.Size = new System.Drawing.Size(171, 26); + this.buttonSortByColor.TabIndex = 12; + this.buttonSortByColor.Text = "Сортировать по цвету"; + this.buttonSortByColor.UseVisualStyleBackColor = true; + this.buttonSortByColor.Click += new System.EventHandler(this.buttonSortByColor_Click); + // // FormMapWithSetPlanes // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(857, 640); + this.ClientSize = new System.Drawing.Size(857, 698); this.Controls.Add(this.pictureBox); this.Controls.Add(this.groupBox1); this.Controls.Add(this.menuStrip1); @@ -330,5 +354,7 @@ private ToolStripMenuItem LoadToolStripMenuItem; private OpenFileDialog openFileDialog; private SaveFileDialog saveFileDialog; + private Button buttonSortByColor; + private Button buttonSortByType; } } \ No newline at end of file diff --git a/Airbus/Airbus/FormMapWithSetPlanes.cs b/Airbus/Airbus/FormMapWithSetPlanes.cs index 6b0c7bd..30a787f 100644 --- a/Airbus/Airbus/FormMapWithSetPlanes.cs +++ b/Airbus/Airbus/FormMapWithSetPlanes.cs @@ -295,5 +295,25 @@ namespace Airbus } } } + + private void buttonSortByType_Click(object sender, EventArgs e) + { + if (listBoxMaps.SelectedIndex == -1) + { + return; + } + _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].Sort(new PlaneCompareByType()); + pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); + } + + private void buttonSortByColor_Click(object sender, EventArgs e) + { + if (listBoxMaps.SelectedIndex == -1) + { + return; + } + _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].Sort(new PlaneCompareByColor()); + pictureBox.Image = _mapsCollection[listBoxMaps.SelectedItem?.ToString() ?? string.Empty].ShowSet(); + } } } diff --git a/Airbus/Airbus/MapWithSetPlanesGeneric.cs b/Airbus/Airbus/MapWithSetPlanesGeneric.cs index 4abb1ea..0f68f09 100644 --- a/Airbus/Airbus/MapWithSetPlanesGeneric.cs +++ b/Airbus/Airbus/MapWithSetPlanesGeneric.cs @@ -212,5 +212,9 @@ namespace Airbus _setPlanes.Insert(DrawningObjectPlane.Create(rec) as T); } } + public void Sort(IComparer comparer) + { + _setPlanes.SortSet(comparer); + } } } diff --git a/Airbus/Airbus/PlaneCompareByColor.cs b/Airbus/Airbus/PlaneCompareByColor.cs new file mode 100644 index 0000000..f7c0708 --- /dev/null +++ b/Airbus/Airbus/PlaneCompareByColor.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Airbus +{ + internal class PlaneCompareByColor : IComparer + { + public int Compare(IDrawningObject? x, IDrawningObject? y) + { + throw new NotImplementedException(); + } + } +} diff --git a/Airbus/Airbus/PlaneCompareByType.cs b/Airbus/Airbus/PlaneCompareByType.cs new file mode 100644 index 0000000..f86d7d3 --- /dev/null +++ b/Airbus/Airbus/PlaneCompareByType.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Airbus +{ + internal class PlaneCompareByType : IComparer + { + public int Compare(IDrawningObject? x, IDrawningObject? y) + { + if (x == null && y == null) + { + return 0; + } + if (x == null && y != null) + { + return 1; + } + if (x != null && y == null) + { + return -1; + } + var xPlane = x as DrawningObjectPlane; + var yPlane = y as DrawningObjectPlane; + if (xPlane == null && yPlane == null) + { + return 0; + } + if (xPlane == null && yPlane != null) + { + return 1; + } + if (xPlane != null && yPlane == null) + { + return -1; + } + if (xPlane.GetPlane.GetType().Name != yPlane.GetPlane.GetType().Name) + { + if (xPlane.GetPlane.GetType().Name == "DrawningPlane") + { + return -1; + } + return 1; + } + var speedCompare = xPlane.GetPlane.Plane.Speed.CompareTo(yPlane.GetPlane.Plane.Speed); + if (speedCompare != 0) + { + return speedCompare; + } + return xPlane.GetPlane.Plane.Weight.CompareTo(yPlane.GetPlane.Plane.Weight); + } + } +} diff --git a/Airbus/Airbus/SetPlanesGeneric.cs b/Airbus/Airbus/SetPlanesGeneric.cs index 0e6a6b9..e3069c5 100644 --- a/Airbus/Airbus/SetPlanesGeneric.cs +++ b/Airbus/Airbus/SetPlanesGeneric.cs @@ -117,5 +117,14 @@ namespace Airbus } } } + public void SortSet(IComparer comparer) + { + if (comparer == null) + { + return; + } + _places.Sort(comparer); + } + } } -- 2.25.1 From 2f7700a12e46c6b078a57dbd343994190a318e78 Mon Sep 17 00:00:00 2001 From: ArtemEmelyanov Date: Fri, 9 Dec 2022 12:39:15 +0400 Subject: [PATCH 3/4] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D0=BD=D0=BD?= =?UTF-8?q?=D0=B0=D1=8F=20=D0=BB=D0=B0=D0=B1=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Airbus/Airbus/AbstractMap.cs | 29 +++++++++++++++- Airbus/Airbus/PlaneCompareByColor.cs | 49 +++++++++++++++++++++++++++- 2 files changed, 76 insertions(+), 2 deletions(-) diff --git a/Airbus/Airbus/AbstractMap.cs b/Airbus/Airbus/AbstractMap.cs index bcb2d68..d41f961 100644 --- a/Airbus/Airbus/AbstractMap.cs +++ b/Airbus/Airbus/AbstractMap.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace Airbus { - internal abstract class AbstractMap + internal abstract class AbstractMap : IEquatable { private IDrawningObject _drawningObject = null; protected int[,] _map = null; @@ -121,5 +121,32 @@ namespace Airbus protected abstract void GenerateMap(); protected abstract void DrawRoadPart(Graphics g, int i, int j); protected abstract void DrawBarrierPart(Graphics g, int i, int j); + + public bool Equals(AbstractMap? other) + { + if (other == null || + _map != other._map || + _width != other._width || + _size_x != other._size_x || + _size_y != other._size_y || + _height != other._height || + GetType() != other.GetType() || + _map.GetLength(0) != other._map.GetLength(0) || + _map.GetLength(1) != other._map.GetLength(1)) + { + return false; + } + for (int i = 0; i < _map.GetLength(0); i++) + { + for (int j = 0; j < _map.GetLength(1); j++) + { + if (_map[i, j] != other._map[i, j]) + { + return false; + } + } + } + return true; + } } } diff --git a/Airbus/Airbus/PlaneCompareByColor.cs b/Airbus/Airbus/PlaneCompareByColor.cs index f7c0708..f10aa7f 100644 --- a/Airbus/Airbus/PlaneCompareByColor.cs +++ b/Airbus/Airbus/PlaneCompareByColor.cs @@ -10,7 +10,54 @@ namespace Airbus { public int Compare(IDrawningObject? x, IDrawningObject? y) { - throw new NotImplementedException(); + if (x == null && y == null) + { + return 0; + } + if (x == null && y != null) + { + return 1; + } + if (x != null && y == null) + { + return -1; + } + var xPlane = x as DrawningObjectPlane; + var yPlane = y as DrawningObjectPlane; + if (xPlane == null && yPlane == null) + { + return 0; + } + if (xPlane == null && yPlane != null) + { + return 1; + } + if (xPlane != null && yPlane == null) + { + return -1; + } + string xShipColor = xPlane.GetPlane.Plane.BodyColor.Name; + string yShipColor = yPlane.GetPlane.Plane.BodyColor.Name; + if (xShipColor != yShipColor) + { + return xShipColor.CompareTo(yShipColor); + } + if (xPlane.GetPlane.Plane is EntityAirbus xAirbus && yPlane.GetPlane.Plane is EntityAirbus yAirbus) + { + string xShipDopColor = xAirbus.DopColor.Name; + string yShipDopColor = yAirbus.DopColor.Name; + var dopColorCompare = xShipDopColor.CompareTo(yShipDopColor); + if (dopColorCompare != 0) + { + return dopColorCompare; + } + } + var speedCompare = xPlane.GetPlane.Plane.Speed.CompareTo(yPlane.GetPlane.Plane.Speed); + if (speedCompare != 0) + { + return speedCompare; + } + return xPlane.GetPlane.Plane.Weight.CompareTo(yPlane.GetPlane.Plane.Weight); } } } -- 2.25.1 From 4b2b4e4d2cffd34d0f87bffc361d9f65473c59bd Mon Sep 17 00:00:00 2001 From: ArtemEmelyanov Date: Wed, 14 Dec 2022 13:01:37 +0400 Subject: [PATCH 4/4] =?UTF-8?q?=D0=B3=D0=BE=D1=82=D0=BE=D0=B2=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Airbus/Airbus/DrawningObjectPlane.cs | 6 ++++++ Airbus/Airbus/SetPlanesGeneric.cs | 3 +-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Airbus/Airbus/DrawningObjectPlane.cs b/Airbus/Airbus/DrawningObjectPlane.cs index ba3dab5..9552909 100644 --- a/Airbus/Airbus/DrawningObjectPlane.cs +++ b/Airbus/Airbus/DrawningObjectPlane.cs @@ -61,6 +61,12 @@ namespace Airbus return false; } + if ((plane is EntityAirbus) && !(otherPlanePlane is EntityAirbus) + || !(plane is EntityAirbus) && (otherPlanePlane is EntityAirbus)) + { + return false; + } + if (plane is EntityAirbus airbus && otherPlanePlane is EntityAirbus otherAirbus) { if (airbus.DopColor != otherAirbus.DopColor) diff --git a/Airbus/Airbus/SetPlanesGeneric.cs b/Airbus/Airbus/SetPlanesGeneric.cs index e3069c5..5af02f7 100644 --- a/Airbus/Airbus/SetPlanesGeneric.cs +++ b/Airbus/Airbus/SetPlanesGeneric.cs @@ -35,8 +35,7 @@ namespace Airbus public int Insert(T plane) { if (_places.Count == _maxCount) throw new StorageOverflowException(_maxCount); - _places.Insert(0, plane); - return 0; + return Insert(plane, 0); } /// /// Добавление объекта в набор на конкретную позицию -- 2.25.1