From 48d0a47fcc8081f4382f2fd1e6bdb2f8bd075e90 Mon Sep 17 00:00:00 2001 From: ikswi Date: Tue, 4 Jun 2024 15:41:43 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B2=D1=81=D1=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AbstractCompany.cs | 4 +++ .../ICollectionGenericObjects.cs | 4 +++ .../Entities/EntityMilitaryAircraf.cs | 29 +++++++++++++++++++ .../FormMilitaryAircraftCollection.cs | 4 +++ тренировочный.txt | 2 -- 5 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 AirFighter/AirFighter/Entities/EntityMilitaryAircraf.cs delete mode 100644 тренировочный.txt diff --git a/AirFighter/AirFighter/CollectionGenericObjects/AbstractCompany.cs b/AirFighter/AirFighter/CollectionGenericObjects/AbstractCompany.cs index 1e3b8f4..4a4727b 100644 --- a/AirFighter/AirFighter/CollectionGenericObjects/AbstractCompany.cs +++ b/AirFighter/AirFighter/CollectionGenericObjects/AbstractCompany.cs @@ -114,6 +114,10 @@ public abstract class AbstractCompany return bitmap; } + /// + /// Сортировка + /// + /// Сравнитель объектов public void Sort(IComparer comparer) => _collection?.CollectionSort(comparer); /// diff --git a/AirFighter/AirFighter/CollectionGenericObjects/ICollectionGenericObjects.cs b/AirFighter/AirFighter/CollectionGenericObjects/ICollectionGenericObjects.cs index e673913..e55afb2 100644 --- a/AirFighter/AirFighter/CollectionGenericObjects/ICollectionGenericObjects.cs +++ b/AirFighter/AirFighter/CollectionGenericObjects/ICollectionGenericObjects.cs @@ -59,5 +59,9 @@ public interface ICollectionGenericObjects /// Поэлементый вывод элементов коллекции IEnumerable GetItems(); + /// + /// Сортировка коллекции + /// + /// Сравнитель объектов void CollectionSort(IComparer comparer); } \ No newline at end of file diff --git a/AirFighter/AirFighter/Entities/EntityMilitaryAircraf.cs b/AirFighter/AirFighter/Entities/EntityMilitaryAircraf.cs new file mode 100644 index 0000000..0773701 --- /dev/null +++ b/AirFighter/AirFighter/Entities/EntityMilitaryAircraf.cs @@ -0,0 +1,29 @@ +namespace ProjectAirFighter.Entities; + +/// +/// Класс-сущность "Истребитель" +/// +public class EntityMilitaryAircraf +{ + public int Speed { get; private set; } + + public double Weight { get; private set; } + + public Color BodyColor { get; private set; } + + public double Step => Speed * 100 / Weight; + + /// + /// Конструктор сущности + /// + /// Скорость + /// Вес автомобиля + /// Основной цвет + + public EntityMilitaryAircraf (int speed, double weight, Color bodyColor) + { + Speed = speed; + Weight = weight; + BodyColor = bodyColor; + } +} diff --git a/AirFighter/AirFighter/FormMilitaryAircraftCollection.cs b/AirFighter/AirFighter/FormMilitaryAircraftCollection.cs index 27623b5..5ecfb05 100644 --- a/AirFighter/AirFighter/FormMilitaryAircraftCollection.cs +++ b/AirFighter/AirFighter/FormMilitaryAircraftCollection.cs @@ -302,6 +302,10 @@ public partial class FormMilitaryAircraftCollection : Form CompareMilitaryAircraft(new DrawningMilitaryAircraftCompareByColor()); } + /// + /// Сортировка по сравнителю + /// + /// Сравнитель объектов private void CompareMilitaryAircraft(IComparer comparer) { if (_company == null) diff --git a/тренировочный.txt b/тренировочный.txt deleted file mode 100644 index b385ee4..0000000 --- a/тренировочный.txt +++ /dev/null @@ -1,2 +0,0 @@ -CollectionsStorage -12-Massive-|52|EntityMilitaryAircraft:100:100:Black;EntityAirFighter:100:100:White:False:True:BlueViolet;EntityMilitaryAircraft:100:100:Green;EntityAirFighter:100:100:Blue:True:True:Black; \ No newline at end of file