From e1515f7771916881fa7eafe51fd99a4b4e28f0a1 Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Fri, 2 Dec 2022 12:58:56 +0400 Subject: [PATCH 1/8] =?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?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Airbus/Airbus/DrawningObjectPlane.cs | 36 ++++++++++++++++++++++++ Airbus/Airbus/IDrawningObject.cs | 2 +- Airbus/Airbus/MapWithSetPlanesGeneric.cs | 2 +- Airbus/Airbus/SetPlanesGeneric.cs | 4 ++- 4 files changed, 41 insertions(+), 3 deletions(-) diff --git a/Airbus/Airbus/DrawningObjectPlane.cs b/Airbus/Airbus/DrawningObjectPlane.cs index 695be57..a694d2d 100644 --- a/Airbus/Airbus/DrawningObjectPlane.cs +++ b/Airbus/Airbus/DrawningObjectPlane.cs @@ -46,5 +46,41 @@ namespace Airbus 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 = _airbus.Airbus; + var otherPlanePlane = otherPlane._airbus.Airbus; + + if(plane.Speed != otherPlanePlane.Speed) + { + return false; + } + + if(plane.Weight != otherPlanePlane.Weight) + { + return false; + } + + if(plane.CorpusColor != otherPlanePlane.CorpusColor) + { + return false; + } + + //TODO доделать проверки на случай продвинутого объекта + + return true; + } } } diff --git a/Airbus/Airbus/IDrawningObject.cs b/Airbus/Airbus/IDrawningObject.cs index ae2dff5..076a89c 100644 --- a/Airbus/Airbus/IDrawningObject.cs +++ b/Airbus/Airbus/IDrawningObject.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; namespace Airbus { - internal interface IDrawningObject + internal interface IDrawningObject : IEquatable { //шаг перемещения объекта public float Step { get; } diff --git a/Airbus/Airbus/MapWithSetPlanesGeneric.cs b/Airbus/Airbus/MapWithSetPlanesGeneric.cs index 4917a05..d72eb6d 100644 --- a/Airbus/Airbus/MapWithSetPlanesGeneric.cs +++ b/Airbus/Airbus/MapWithSetPlanesGeneric.cs @@ -10,7 +10,7 @@ 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 70d5559..8c8edac 100644 --- a/Airbus/Airbus/SetPlanesGeneric.cs +++ b/Airbus/Airbus/SetPlanesGeneric.cs @@ -8,7 +8,7 @@ using System.Threading.Tasks; namespace Airbus { internal class SetPlanesGeneric - where T: class + where T: class, IEquatable { //список объектов, которые храним private readonly List _places; @@ -29,6 +29,8 @@ namespace Airbus //добавление объекта в набор public int Insert(T plane) { + //TODO проверка на уникальность элемента в списке, делаем перед сообщением о переполнении + if (Count == _maxCount) { throw new StorageOverflowException(_maxCount); -- 2.25.1 From 91c2c075f39a7c28a042d2d6c2f38fc836def290 Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Fri, 2 Dec 2022 13:23:12 +0400 Subject: [PATCH 2/8] =?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 | 2 + .../Airbus/FormMapWithSetPlanes.Designer.cs | 50 ++++++++++---- Airbus/Airbus/FormMapWithSetPlanes.cs | 12 ++++ Airbus/Airbus/MapWithSetPlanesGeneric.cs | 6 ++ Airbus/Airbus/PlaneCompareByColor.cs | 16 +++++ Airbus/Airbus/PlaneCompareByType.cs | 67 +++++++++++++++++++ Airbus/Airbus/SetPlanesGeneric.cs | 11 +++ 7 files changed, 152 insertions(+), 12 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 a694d2d..ef8fda5 100644 --- a/Airbus/Airbus/DrawningObjectPlane.cs +++ b/Airbus/Airbus/DrawningObjectPlane.cs @@ -17,6 +17,8 @@ namespace Airbus _airbus = airbus; } + public DrawningAirbus GetPlane => _airbus; + void IDrawningObject.DrawningObject(Graphics g) { _airbus.DrawTransport(g); diff --git a/Airbus/Airbus/FormMapWithSetPlanes.Designer.cs b/Airbus/Airbus/FormMapWithSetPlanes.Designer.cs index fd70732..e19c808 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.OpenFileDialog(); + this.buttonSortByType = new System.Windows.Forms.Button(); + this.buttonSortByColor = new System.Windows.Forms.Button(); this.groupBoxTools.SuspendLayout(); this.groupBoxMaps.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit(); @@ -59,6 +61,8 @@ // // groupBoxTools // + this.groupBoxTools.Controls.Add(this.buttonSortByColor); + this.groupBoxTools.Controls.Add(this.buttonSortByType); this.groupBoxTools.Controls.Add(this.groupBoxMaps); this.groupBoxTools.Controls.Add(this.buttonRight); this.groupBoxTools.Controls.Add(this.buttonDown); @@ -72,7 +76,7 @@ this.groupBoxTools.Dock = System.Windows.Forms.DockStyle.Right; this.groupBoxTools.Location = new System.Drawing.Point(843, 28); this.groupBoxTools.Name = "groupBoxTools"; - this.groupBoxTools.Size = new System.Drawing.Size(250, 769); + this.groupBoxTools.Size = new System.Drawing.Size(250, 863); this.groupBoxTools.TabIndex = 0; this.groupBoxTools.TabStop = false; this.groupBoxTools.Text = "Инструменты"; @@ -145,7 +149,7 @@ this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonRight.BackgroundImage = global::Airbus.Properties.Resources.Right; this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; - this.buttonRight.Location = new System.Drawing.Point(158, 704); + this.buttonRight.Location = new System.Drawing.Point(158, 798); this.buttonRight.Name = "buttonRight"; this.buttonRight.Size = new System.Drawing.Size(45, 45); this.buttonRight.TabIndex = 9; @@ -157,7 +161,7 @@ this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonDown.BackgroundImage = global::Airbus.Properties.Resources.Down; this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; - this.buttonDown.Location = new System.Drawing.Point(107, 704); + this.buttonDown.Location = new System.Drawing.Point(107, 798); this.buttonDown.Name = "buttonDown"; this.buttonDown.Size = new System.Drawing.Size(45, 45); this.buttonDown.TabIndex = 8; @@ -169,7 +173,7 @@ this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonLeft.BackgroundImage = global::Airbus.Properties.Resources.Left; this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; - this.buttonLeft.Location = new System.Drawing.Point(56, 704); + this.buttonLeft.Location = new System.Drawing.Point(56, 798); this.buttonLeft.Name = "buttonLeft"; this.buttonLeft.Size = new System.Drawing.Size(45, 45); this.buttonLeft.TabIndex = 7; @@ -181,7 +185,7 @@ this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonUp.BackgroundImage = global::Airbus.Properties.Resources.Up; this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; - this.buttonUp.Location = new System.Drawing.Point(107, 653); + this.buttonUp.Location = new System.Drawing.Point(107, 747); this.buttonUp.Name = "buttonUp"; this.buttonUp.Size = new System.Drawing.Size(45, 45); this.buttonUp.TabIndex = 6; @@ -190,7 +194,7 @@ // // buttonShowOnMap // - this.buttonShowOnMap.Location = new System.Drawing.Point(20, 553); + this.buttonShowOnMap.Location = new System.Drawing.Point(20, 687); this.buttonShowOnMap.Name = "buttonShowOnMap"; this.buttonShowOnMap.Size = new System.Drawing.Size(218, 29); this.buttonShowOnMap.TabIndex = 5; @@ -200,7 +204,7 @@ // // buttonShowStorage // - this.buttonShowStorage.Location = new System.Drawing.Point(20, 500); + this.buttonShowStorage.Location = new System.Drawing.Point(20, 634); this.buttonShowStorage.Name = "buttonShowStorage"; this.buttonShowStorage.Size = new System.Drawing.Size(218, 29); this.buttonShowStorage.TabIndex = 4; @@ -210,7 +214,7 @@ // // buttonRemovePlane // - this.buttonRemovePlane.Location = new System.Drawing.Point(20, 446); + this.buttonRemovePlane.Location = new System.Drawing.Point(20, 580); this.buttonRemovePlane.Name = "buttonRemovePlane"; this.buttonRemovePlane.Size = new System.Drawing.Size(218, 29); this.buttonRemovePlane.TabIndex = 3; @@ -220,7 +224,7 @@ // // maskedTextBoxPosition // - this.maskedTextBoxPosition.Location = new System.Drawing.Point(20, 413); + this.maskedTextBoxPosition.Location = new System.Drawing.Point(20, 547); this.maskedTextBoxPosition.Mask = "00"; this.maskedTextBoxPosition.Name = "maskedTextBoxPosition"; this.maskedTextBoxPosition.Size = new System.Drawing.Size(218, 27); @@ -228,7 +232,7 @@ // // buttonAddPlane // - this.buttonAddPlane.Location = new System.Drawing.Point(20, 378); + this.buttonAddPlane.Location = new System.Drawing.Point(20, 512); this.buttonAddPlane.Name = "buttonAddPlane"; this.buttonAddPlane.Size = new System.Drawing.Size(218, 29); this.buttonAddPlane.TabIndex = 1; @@ -241,7 +245,7 @@ this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill; this.pictureBox.Location = new System.Drawing.Point(0, 28); this.pictureBox.Name = "pictureBox"; - this.pictureBox.Size = new System.Drawing.Size(843, 769); + this.pictureBox.Size = new System.Drawing.Size(843, 863); this.pictureBox.TabIndex = 1; this.pictureBox.TabStop = false; // @@ -287,11 +291,31 @@ // this.saveFileDialog.Filter = "txt file | *.txt"; // + // buttonSortByType + // + this.buttonSortByType.Location = new System.Drawing.Point(20, 395); + this.buttonSortByType.Name = "buttonSortByType"; + this.buttonSortByType.Size = new System.Drawing.Size(218, 29); + 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(20, 430); + this.buttonSortByColor.Name = "buttonSortByColor"; + this.buttonSortByColor.Size = new System.Drawing.Size(218, 29); + 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(8F, 20F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1093, 797); + this.ClientSize = new System.Drawing.Size(1093, 891); this.Controls.Add(this.pictureBox); this.Controls.Add(this.groupBoxTools); this.Controls.Add(this.menuStrip); @@ -335,5 +359,7 @@ private ToolStripMenuItem LoadToolStripMenuItem; private OpenFileDialog openFileDialog; private OpenFileDialog 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 18f4ffd..2a3b111 100644 --- a/Airbus/Airbus/FormMapWithSetPlanes.cs +++ b/Airbus/Airbus/FormMapWithSetPlanes.cs @@ -292,5 +292,17 @@ namespace Airbus } } } + + //сортировка по типу + private void buttonSortByType_Click(object sender, EventArgs e) + { + + } + + //сортировка по цвету + private void buttonSortByColor_Click(object sender, EventArgs e) + { + //TODO прописать логику + } } } diff --git a/Airbus/Airbus/MapWithSetPlanesGeneric.cs b/Airbus/Airbus/MapWithSetPlanesGeneric.cs index d72eb6d..a67988d 100644 --- a/Airbus/Airbus/MapWithSetPlanesGeneric.cs +++ b/Airbus/Airbus/MapWithSetPlanesGeneric.cs @@ -108,6 +108,12 @@ namespace Airbus } } + //сортировка + public void Sort(IComparer comparer) + { + _setPlanes.SortSet(comparer); + } + //"взламываем" набор, чтобы все элементы оказались в начале private void Shaking() { diff --git a/Airbus/Airbus/PlaneCompareByColor.cs b/Airbus/Airbus/PlaneCompareByColor.cs new file mode 100644 index 0000000..b70aa65 --- /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) + { + //TODO проверку + } + } +} diff --git a/Airbus/Airbus/PlaneCompareByType.cs b/Airbus/Airbus/PlaneCompareByType.cs new file mode 100644 index 0000000..1c9b86b --- /dev/null +++ b/Airbus/Airbus/PlaneCompareByType.cs @@ -0,0 +1,67 @@ +using Microsoft.Extensions.Logging.Abstractions; +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 == "DrawningAirbus") + { + return -1; + } + + return -1; + } + + var speedCompare = xPlane.GetPlane.Airbus.Speed.CompareTo(yPlane.GetPlane.Airbus.Speed); + + if(speedCompare != 0) + { + return speedCompare; + } + + return xPlane.GetPlane.Airbus.Speed.CompareTo(yPlane.GetPlane.Airbus.Speed); + } + } +} diff --git a/Airbus/Airbus/SetPlanesGeneric.cs b/Airbus/Airbus/SetPlanesGeneric.cs index 8c8edac..364519d 100644 --- a/Airbus/Airbus/SetPlanesGeneric.cs +++ b/Airbus/Airbus/SetPlanesGeneric.cs @@ -114,5 +114,16 @@ namespace Airbus } } } + + //сортировка набора объектов + public void SortSet(IComparer comparer) + { + if(comparer == null) + { + return; + } + + _places.Sort(comparer); + } } } -- 2.25.1 From 535dbe7e440b2a522c6f2da11607ebf49541cfb1 Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Fri, 2 Dec 2022 14:16:39 +0400 Subject: [PATCH 3/8] =?UTF-8?q?=D0=94=D0=BE=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=BA=D0=B8=208-=D0=B9=20=D0=BB=D0=B0=D0=B1=D0=BE=D1=80=D0=B0?= =?UTF-8?q?=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/AbstractMap.cs | 27 +++++++- Airbus/Airbus/DrawningObjectPlane.cs | 18 ++++- .../Airbus/FormMapWithSetPlanes.Designer.cs | 68 +++++++++---------- Airbus/Airbus/FormMapWithSetPlanes.cs | 14 +++- Airbus/Airbus/PlaneCompareByColor.cs | 44 +++++++++++- Airbus/Airbus/SetPlanesGeneric.cs | 5 +- 6 files changed, 137 insertions(+), 39 deletions(-) diff --git a/Airbus/Airbus/AbstractMap.cs b/Airbus/Airbus/AbstractMap.cs index 916a451..db12436 100644 --- a/Airbus/Airbus/AbstractMap.cs +++ b/Airbus/Airbus/AbstractMap.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; namespace Airbus { - internal abstract class AbstractMap + internal abstract class AbstractMap : IEquatable { private IDrawningObject _drawningObject = null; protected int[,] _map = null; @@ -166,6 +166,31 @@ namespace Airbus return bmp; } + //сравнение + + public bool Equals(AbstractMap? other) + { + if (other == null || _map != other._map || _height != other._height || _width != other._width + || _size_x != other._size_x || _size_y != other._size_y || 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; + } + protected abstract void GenerateMap(); protected abstract void DrawRoadPart(Graphics g, int i, int j); protected abstract void DrawBarrierPart(Graphics g, int i, int j); diff --git a/Airbus/Airbus/DrawningObjectPlane.cs b/Airbus/Airbus/DrawningObjectPlane.cs index ef8fda5..0eead77 100644 --- a/Airbus/Airbus/DrawningObjectPlane.cs +++ b/Airbus/Airbus/DrawningObjectPlane.cs @@ -80,7 +80,23 @@ namespace Airbus return false; } - //TODO доделать проверки на случай продвинутого объекта + if(plane is EntitySuperAirbus entitySuperAirbus && otherPlanePlane is EntitySuperAirbus otherEntitySuperAirbus) + { + if(entitySuperAirbus.AddEngine != otherEntitySuperAirbus.AddEngine) + { + return false; + } + + if(entitySuperAirbus.AddСompartment != otherEntitySuperAirbus.AddСompartment) + { + return false; + } + + if(entitySuperAirbus.AddColor.ToArgb() != otherEntitySuperAirbus.AddColor.ToArgb()) + { + return false; + } + } return true; } diff --git a/Airbus/Airbus/FormMapWithSetPlanes.Designer.cs b/Airbus/Airbus/FormMapWithSetPlanes.Designer.cs index e19c808..c422579 100644 --- a/Airbus/Airbus/FormMapWithSetPlanes.Designer.cs +++ b/Airbus/Airbus/FormMapWithSetPlanes.Designer.cs @@ -29,6 +29,8 @@ private void InitializeComponent() { this.groupBoxTools = new System.Windows.Forms.GroupBox(); + this.buttonSortByColor = new System.Windows.Forms.Button(); + this.buttonSortByType = new System.Windows.Forms.Button(); this.groupBoxMaps = new System.Windows.Forms.GroupBox(); this.buttonDeleteMap = new System.Windows.Forms.Button(); this.listBoxMaps = new System.Windows.Forms.ListBox(); @@ -51,8 +53,6 @@ this.LoadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.openFileDialog = new System.Windows.Forms.OpenFileDialog(); this.saveFileDialog = new System.Windows.Forms.OpenFileDialog(); - this.buttonSortByType = new System.Windows.Forms.Button(); - this.buttonSortByColor = new System.Windows.Forms.Button(); this.groupBoxTools.SuspendLayout(); this.groupBoxMaps.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit(); @@ -76,11 +76,31 @@ this.groupBoxTools.Dock = System.Windows.Forms.DockStyle.Right; this.groupBoxTools.Location = new System.Drawing.Point(843, 28); this.groupBoxTools.Name = "groupBoxTools"; - this.groupBoxTools.Size = new System.Drawing.Size(250, 863); + this.groupBoxTools.Size = new System.Drawing.Size(250, 805); this.groupBoxTools.TabIndex = 0; this.groupBoxTools.TabStop = false; this.groupBoxTools.Text = "Инструменты"; // + // buttonSortByColor + // + this.buttonSortByColor.Location = new System.Drawing.Point(20, 416); + this.buttonSortByColor.Name = "buttonSortByColor"; + this.buttonSortByColor.Size = new System.Drawing.Size(218, 29); + this.buttonSortByColor.TabIndex = 12; + this.buttonSortByColor.Text = "Сортировка по цвету"; + this.buttonSortByColor.UseVisualStyleBackColor = true; + this.buttonSortByColor.Click += new System.EventHandler(this.buttonSortByColor_Click); + // + // buttonSortByType + // + this.buttonSortByType.Location = new System.Drawing.Point(20, 381); + this.buttonSortByType.Name = "buttonSortByType"; + this.buttonSortByType.Size = new System.Drawing.Size(218, 29); + this.buttonSortByType.TabIndex = 11; + this.buttonSortByType.Text = "Сортировка по типу"; + this.buttonSortByType.UseVisualStyleBackColor = true; + this.buttonSortByType.Click += new System.EventHandler(this.buttonSortByType_Click); + // // groupBoxMaps // this.groupBoxMaps.Controls.Add(this.buttonDeleteMap); @@ -149,7 +169,7 @@ this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonRight.BackgroundImage = global::Airbus.Properties.Resources.Right; this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; - this.buttonRight.Location = new System.Drawing.Point(158, 798); + this.buttonRight.Location = new System.Drawing.Point(158, 740); this.buttonRight.Name = "buttonRight"; this.buttonRight.Size = new System.Drawing.Size(45, 45); this.buttonRight.TabIndex = 9; @@ -161,7 +181,7 @@ this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonDown.BackgroundImage = global::Airbus.Properties.Resources.Down; this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; - this.buttonDown.Location = new System.Drawing.Point(107, 798); + this.buttonDown.Location = new System.Drawing.Point(107, 740); this.buttonDown.Name = "buttonDown"; this.buttonDown.Size = new System.Drawing.Size(45, 45); this.buttonDown.TabIndex = 8; @@ -173,7 +193,7 @@ this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonLeft.BackgroundImage = global::Airbus.Properties.Resources.Left; this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; - this.buttonLeft.Location = new System.Drawing.Point(56, 798); + this.buttonLeft.Location = new System.Drawing.Point(56, 740); this.buttonLeft.Name = "buttonLeft"; this.buttonLeft.Size = new System.Drawing.Size(45, 45); this.buttonLeft.TabIndex = 7; @@ -185,7 +205,7 @@ this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonUp.BackgroundImage = global::Airbus.Properties.Resources.Up; this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom; - this.buttonUp.Location = new System.Drawing.Point(107, 747); + this.buttonUp.Location = new System.Drawing.Point(107, 689); this.buttonUp.Name = "buttonUp"; this.buttonUp.Size = new System.Drawing.Size(45, 45); this.buttonUp.TabIndex = 6; @@ -194,7 +214,7 @@ // // buttonShowOnMap // - this.buttonShowOnMap.Location = new System.Drawing.Point(20, 687); + this.buttonShowOnMap.Location = new System.Drawing.Point(20, 642); this.buttonShowOnMap.Name = "buttonShowOnMap"; this.buttonShowOnMap.Size = new System.Drawing.Size(218, 29); this.buttonShowOnMap.TabIndex = 5; @@ -204,7 +224,7 @@ // // buttonShowStorage // - this.buttonShowStorage.Location = new System.Drawing.Point(20, 634); + this.buttonShowStorage.Location = new System.Drawing.Point(20, 589); this.buttonShowStorage.Name = "buttonShowStorage"; this.buttonShowStorage.Size = new System.Drawing.Size(218, 29); this.buttonShowStorage.TabIndex = 4; @@ -214,7 +234,7 @@ // // buttonRemovePlane // - this.buttonRemovePlane.Location = new System.Drawing.Point(20, 580); + this.buttonRemovePlane.Location = new System.Drawing.Point(20, 535); this.buttonRemovePlane.Name = "buttonRemovePlane"; this.buttonRemovePlane.Size = new System.Drawing.Size(218, 29); this.buttonRemovePlane.TabIndex = 3; @@ -224,7 +244,7 @@ // // maskedTextBoxPosition // - this.maskedTextBoxPosition.Location = new System.Drawing.Point(20, 547); + this.maskedTextBoxPosition.Location = new System.Drawing.Point(20, 502); this.maskedTextBoxPosition.Mask = "00"; this.maskedTextBoxPosition.Name = "maskedTextBoxPosition"; this.maskedTextBoxPosition.Size = new System.Drawing.Size(218, 27); @@ -232,7 +252,7 @@ // // buttonAddPlane // - this.buttonAddPlane.Location = new System.Drawing.Point(20, 512); + this.buttonAddPlane.Location = new System.Drawing.Point(20, 467); this.buttonAddPlane.Name = "buttonAddPlane"; this.buttonAddPlane.Size = new System.Drawing.Size(218, 29); this.buttonAddPlane.TabIndex = 1; @@ -245,7 +265,7 @@ this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill; this.pictureBox.Location = new System.Drawing.Point(0, 28); this.pictureBox.Name = "pictureBox"; - this.pictureBox.Size = new System.Drawing.Size(843, 863); + this.pictureBox.Size = new System.Drawing.Size(843, 805); this.pictureBox.TabIndex = 1; this.pictureBox.TabStop = false; // @@ -291,31 +311,11 @@ // this.saveFileDialog.Filter = "txt file | *.txt"; // - // buttonSortByType - // - this.buttonSortByType.Location = new System.Drawing.Point(20, 395); - this.buttonSortByType.Name = "buttonSortByType"; - this.buttonSortByType.Size = new System.Drawing.Size(218, 29); - 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(20, 430); - this.buttonSortByColor.Name = "buttonSortByColor"; - this.buttonSortByColor.Size = new System.Drawing.Size(218, 29); - 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(8F, 20F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1093, 891); + this.ClientSize = new System.Drawing.Size(1093, 833); this.Controls.Add(this.pictureBox); this.Controls.Add(this.groupBoxTools); this.Controls.Add(this.menuStrip); diff --git a/Airbus/Airbus/FormMapWithSetPlanes.cs b/Airbus/Airbus/FormMapWithSetPlanes.cs index 2a3b111..865c675 100644 --- a/Airbus/Airbus/FormMapWithSetPlanes.cs +++ b/Airbus/Airbus/FormMapWithSetPlanes.cs @@ -296,13 +296,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) { - //TODO прописать логику + 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/PlaneCompareByColor.cs b/Airbus/Airbus/PlaneCompareByColor.cs index b70aa65..a32410d 100644 --- a/Airbus/Airbus/PlaneCompareByColor.cs +++ b/Airbus/Airbus/PlaneCompareByColor.cs @@ -10,7 +10,49 @@ namespace Airbus { public int Compare(IDrawningObject? x, IDrawningObject? y) { - //TODO проверку + 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; + } + + var xEntity = xPlane.GetPlane.Airbus; + var yEntity = yPlane.GetPlane.Airbus; + var colorCompare = xEntity.CorpusColor.ToArgb().CompareTo(yEntity.CorpusColor.ToArgb()); + + if (colorCompare != 0 || xEntity is not EntitySuperAirbus xEntityAirbus || yEntity is not EntitySuperAirbus yEntityAirbus) + { + return colorCompare; + } + + return xEntityAirbus.AddColor.ToArgb().CompareTo(yEntityAirbus.AddColor.ToArgb()); } } } diff --git a/Airbus/Airbus/SetPlanesGeneric.cs b/Airbus/Airbus/SetPlanesGeneric.cs index 364519d..301ab42 100644 --- a/Airbus/Airbus/SetPlanesGeneric.cs +++ b/Airbus/Airbus/SetPlanesGeneric.cs @@ -29,7 +29,10 @@ namespace Airbus //добавление объекта в набор public int Insert(T plane) { - //TODO проверка на уникальность элемента в списке, делаем перед сообщением о переполнении + if (_places.Contains(plane)) + { + throw new ArgumentException($"Объект {plane} уже есть в данном наборе"); + } if (Count == _maxCount) { -- 2.25.1 From acba9f20715565754d5723588c72f10b59d5cd16 Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Sat, 3 Dec 2022 15:22:28 +0400 Subject: [PATCH 4/8] =?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; -- 2.25.1 From d5f6a0415262b6c493e814bc68e1aaf19e190b05 Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Sat, 3 Dec 2022 17:52:39 +0400 Subject: [PATCH 5/8] =?UTF-8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=208-?= =?UTF-8?q?=D0=B9=20=D0=BB=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82=D0=BE=D1=80?= =?UTF-8?q?=D0=BD=D0=BE=D0=B9.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Airbus/Airbus/PlaneCompareByColor.cs | 10 ++++++++++ Airbus/Airbus/PlaneCompareByType.cs | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Airbus/Airbus/PlaneCompareByColor.cs b/Airbus/Airbus/PlaneCompareByColor.cs index 388d7c3..77538ef 100644 --- a/Airbus/Airbus/PlaneCompareByColor.cs +++ b/Airbus/Airbus/PlaneCompareByColor.cs @@ -43,6 +43,16 @@ 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); diff --git a/Airbus/Airbus/PlaneCompareByType.cs b/Airbus/Airbus/PlaneCompareByType.cs index 1c9b86b..3524e2f 100644 --- a/Airbus/Airbus/PlaneCompareByType.cs +++ b/Airbus/Airbus/PlaneCompareByType.cs @@ -61,7 +61,7 @@ namespace Airbus return speedCompare; } - return xPlane.GetPlane.Airbus.Speed.CompareTo(yPlane.GetPlane.Airbus.Speed); + return xPlane.GetPlane.Airbus.Weight.CompareTo(yPlane.GetPlane.Airbus.Weight); } } } -- 2.25.1 From 519ba5ef7a008d25aff7baf9915c29e4cd899387 Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Sat, 3 Dec 2022 20:56:25 +0400 Subject: [PATCH 6/8] =?UTF-8?q?=D0=9C=D0=B5=D0=BB=D0=BA=D0=B8=D0=B5=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=208-=D0=B9=20=D0=BB=D0=B0?= =?UTF-8?q?=D0=B1=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); } } } -- 2.25.1 From f5fb433b765fb46710f0b943ff1c694ec047397c Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Mon, 5 Dec 2022 19:25:49 +0400 Subject: [PATCH 7/8] =?UTF-8?q?=D0=9D=D0=B0=D1=81=D1=82=D1=80=D0=BE=D0=B9?= =?UTF-8?q?=D0=BA=D0=B0=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D1=8B=20=D1=81?= =?UTF-8?q?=D1=82=D1=80=D0=B0=D0=B2=D0=BD=D0=B5=D0=BD=D0=B8=D1=8F.=208-?= =?UTF-8?q?=D1=8F=20=D0=BB=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82=D0=BE=D1=80?= =?UTF-8?q?=D0=BD=D0=B0=D1=8F.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Airbus/FormMapWithSetPlanes.Designer.cs | 4 ++-- Airbus/Airbus/FormMapWithSetPlanes.cs | 4 ++-- Airbus/Airbus/PlaneCompareByColor.cs | 21 ++++++++----------- Airbus/Airbus/PlaneCompareByType.cs | 6 +++--- Airbus/Airbus/SaveData.txt | 2 +- 5 files changed, 17 insertions(+), 20 deletions(-) diff --git a/Airbus/Airbus/FormMapWithSetPlanes.Designer.cs b/Airbus/Airbus/FormMapWithSetPlanes.Designer.cs index c422579..43df6fd 100644 --- a/Airbus/Airbus/FormMapWithSetPlanes.Designer.cs +++ b/Airbus/Airbus/FormMapWithSetPlanes.Designer.cs @@ -89,7 +89,7 @@ this.buttonSortByColor.TabIndex = 12; this.buttonSortByColor.Text = "Сортировка по цвету"; this.buttonSortByColor.UseVisualStyleBackColor = true; - this.buttonSortByColor.Click += new System.EventHandler(this.buttonSortByColor_Click); + this.buttonSortByColor.Click += new System.EventHandler(this.ButtonSortByColor_Click); // // buttonSortByType // @@ -99,7 +99,7 @@ this.buttonSortByType.TabIndex = 11; this.buttonSortByType.Text = "Сортировка по типу"; this.buttonSortByType.UseVisualStyleBackColor = true; - this.buttonSortByType.Click += new System.EventHandler(this.buttonSortByType_Click); + this.buttonSortByType.Click += new System.EventHandler(this.ButtonSortByType_Click); // // groupBoxMaps // diff --git a/Airbus/Airbus/FormMapWithSetPlanes.cs b/Airbus/Airbus/FormMapWithSetPlanes.cs index 865c675..6eb55ad 100644 --- a/Airbus/Airbus/FormMapWithSetPlanes.cs +++ b/Airbus/Airbus/FormMapWithSetPlanes.cs @@ -294,7 +294,7 @@ namespace Airbus } //сортировка по типу - private void buttonSortByType_Click(object sender, EventArgs e) + private void ButtonSortByType_Click(object sender, EventArgs e) { if(listBoxMaps.SelectedIndex == -1) { @@ -306,7 +306,7 @@ namespace Airbus } //сортировка по цвету - private void buttonSortByColor_Click(object sender, EventArgs e) + private void ButtonSortByColor_Click(object sender, EventArgs e) { if (listBoxMaps.SelectedIndex == -1) { diff --git a/Airbus/Airbus/PlaneCompareByColor.cs b/Airbus/Airbus/PlaneCompareByColor.cs index 92295b6..0606000 100644 --- a/Airbus/Airbus/PlaneCompareByColor.cs +++ b/Airbus/Airbus/PlaneCompareByColor.cs @@ -20,7 +20,7 @@ namespace Airbus return 1; } - if (x != null && y != null) + if (x != null && y == null) { return -1; } @@ -40,28 +40,25 @@ namespace Airbus if (xPlane != null && yPlane == null) { - return 1; + return -1; } - var xEntity = xPlane.GetPlane.Airbus; - var yEntity = yPlane.GetPlane.Airbus; - var colorCompare = xEntity.CorpusColor.ToArgb().CompareTo(yEntity.CorpusColor.ToArgb()); - - int i = xEntity.CorpusColor.ToArgb(); - int j = yEntity.CorpusColor.ToArgb(); + var xEntityPlane = xPlane.GetPlane.Airbus; + var yEntityPlane = yPlane.GetPlane.Airbus; + var colorCompare = xEntityPlane.CorpusColor.ToArgb().CompareTo(yEntityPlane.CorpusColor.ToArgb()); if (colorCompare != 0) { return colorCompare; } - if (xEntity is EntitySuperAirbus xEntityAirbus && yEntity is EntitySuperAirbus yEntityAirbus) + if (xEntityPlane is EntitySuperAirbus xAirbus && yEntityPlane is EntitySuperAirbus yAirbus) { - var addColorCompare = xEntityAirbus.AddColor.ToArgb().CompareTo(yEntityAirbus.AddColor.ToArgb()); + var dopColorCompare = xAirbus.AddColor.ToArgb().CompareTo(yAirbus.AddColor.ToArgb()); - if(addColorCompare != 0) + if (dopColorCompare != 0) { - return addColorCompare; + return dopColorCompare; } } diff --git a/Airbus/Airbus/PlaneCompareByType.cs b/Airbus/Airbus/PlaneCompareByType.cs index 3524e2f..bf93c01 100644 --- a/Airbus/Airbus/PlaneCompareByType.cs +++ b/Airbus/Airbus/PlaneCompareByType.cs @@ -21,7 +21,7 @@ namespace Airbus return 1; } - if(x != null && y != null) + if(x != null && y == null) { return -1; } @@ -41,7 +41,7 @@ namespace Airbus if(xPlane != null && yPlane == null) { - return 1; + return -1; } if(xPlane.GetPlane.GetType().Name != yPlane.GetPlane.GetType().Name) @@ -51,7 +51,7 @@ namespace Airbus return -1; } - return -1; + return 1; } var speedCompare = xPlane.GetPlane.Airbus.Speed.CompareTo(yPlane.GetPlane.Airbus.Speed); diff --git a/Airbus/Airbus/SaveData.txt b/Airbus/Airbus/SaveData.txt index bcb8f5d..608f1fd 100644 --- a/Airbus/Airbus/SaveData.txt +++ b/Airbus/Airbus/SaveData.txt @@ -1,2 +1,2 @@ MapsCollection -345|DesertStormMap|1000:750:Black:Yellow:False:True;1010:760:Yellow;1005:755:Lime; +345|DesertStormMap|1000:750:White:Gray:True:True;1000:750:DeepPink:Yellow:False:True;1001:751:Red;1000:750:Red;1005:755:Lime;1010:760:Yellow;1000:750:Black:Yellow:True:False; -- 2.25.1 From 035b2c4ab51aa9b2c3e2205c4be7a0aedf4066fb Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Thu, 8 Dec 2022 22:43:46 +0400 Subject: [PATCH 8/8] =?UTF-8?q?=D0=97=D0=B0=D0=B2=D0=B5=D1=80=D1=88=D1=91?= =?UTF-8?q?=D0=BD=D0=BD=D0=B0=D1=8F=208-=D1=8F=20=D0=BB=D0=B0=D0=B1=D0=BE?= =?UTF-8?q?=D1=80=D0=B0=D1=82=D0=BE=D1=80=D0=BD=D0=B0=D1=8F.=20=D0=A3?= =?UTF-8?q?=D1=80=D0=B0!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Airbus/Airbus/AbstractMap.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Airbus/Airbus/AbstractMap.cs b/Airbus/Airbus/AbstractMap.cs index db12436..a120000 100644 --- a/Airbus/Airbus/AbstractMap.cs +++ b/Airbus/Airbus/AbstractMap.cs @@ -167,7 +167,6 @@ namespace Airbus } //сравнение - public bool Equals(AbstractMap? other) { if (other == null || _map != other._map || _height != other._height || _width != other._width -- 2.25.1