From f577b5ac4fe10e76e2704e51308d1f5bddeb83ea Mon Sep 17 00:00:00 2001 From: ivans Date: Wed, 12 Jun 2024 21:34:13 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=B1=D1=80=D0=B0=D0=BD=D1=8B=20=D0=BD?= =?UTF-8?q?=D0=B5=D0=BA=D0=BE=D1=82=D0=BE=D1=80=D1=8B=D0=B5=20=D0=BB=D0=B8?= =?UTF-8?q?=D1=88=D0=BD=D0=B8=D0=B5=20=D0=BF=D1=83=D1=81=D1=82=D1=8B=D0=B5?= =?UTF-8?q?=20=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CollectionGenericObjects/AbstractCompany.cs | 13 ------------- .../ICollectionGenericObjects.cs | 5 ----- .../ListGenericObjects.cs | 2 -- .../MassiveGenericObjects.cs | 8 +------- .../CollectionGenericObjects/StorageCollection.cs | 15 ++++----------- .../ProjectSeaplane/FormPlaneCollection.cs | 12 ------------ 6 files changed, 5 insertions(+), 50 deletions(-) diff --git a/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/AbstractCompany.cs b/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/AbstractCompany.cs index ba5cc2c..2558745 100644 --- a/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/AbstractCompany.cs +++ b/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/AbstractCompany.cs @@ -10,32 +10,26 @@ public abstract class AbstractCompany /// Размер места (ширина) /// protected readonly int _placeSizeWidth = 180; - /// /// Размер места (высота) /// protected readonly int _placeSizeHeight = 100; - /// /// Ширина окна /// protected readonly int _pictureWidth; - /// /// Высота окна /// protected readonly int _pictureHeight; - /// /// Коллекция cамолетов /// protected ICollectionGenericObjects? _collection = null; - /// /// Вычисление максимального количества элементов, который можно разместить в окне /// private int GetMaxCount => (_pictureWidth * _pictureHeight / (_placeSizeWidth * _placeSizeHeight))-15; - /// /// Конструктор /// @@ -49,7 +43,6 @@ public abstract class AbstractCompany _collection = collection; _collection.MaxCount = GetMaxCount; } - /// /// Перегрузка оператора сложения для класса /// @@ -60,7 +53,6 @@ public abstract class AbstractCompany { return company._collection.Insert(seaplane, new DrawingSeaplaneEqutables()); } - /// /// Перегрузка оператора удаления для класса /// @@ -71,7 +63,6 @@ public abstract class AbstractCompany { return company._collection?.Remove(position); } - /// /// Получение случайного объекта из коллекции /// @@ -81,7 +72,6 @@ public abstract class AbstractCompany Random rnd = new(); return _collection?.Get(rnd.Next(GetMaxCount)); } - /// /// Вывод всей коллекции /// @@ -105,18 +95,15 @@ public abstract class AbstractCompany return bitmap; } - /// /// Вывод заднего фона /// /// protected abstract void DrawBackgound(Graphics g); - /// /// Расстановка объектов /// protected abstract void SetObjectsPosition(); - /// /// Сортировка /// diff --git a/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/ICollectionGenericObjects.cs b/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/ICollectionGenericObjects.cs index 8cd1d37..50cf067 100644 --- a/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/ICollectionGenericObjects.cs +++ b/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/ICollectionGenericObjects.cs @@ -11,19 +11,16 @@ public interface ICollectionGenericObjects /// Количество объектов в коллекции /// int Count { get; } - /// /// Установка максимального количества элементов /// int MaxCount { get; set; } - /// /// Добавление объекта в коллекцию /// /// Добавляемый объект /// true - вставка прошла удачно, false - вставка не удалась int Insert(T obj, IEqualityComparer? compaper = null); - /// /// Добавление объекта в коллекцию на конкретную позицию /// @@ -31,14 +28,12 @@ public interface ICollectionGenericObjects /// Позиция /// true - вставка прошла удачно, false - вставка не удалась int Insert(T obj, int position, IEqualityComparer? compaper = null); - /// /// Удаление объекта из коллекции с конкретной позиции /// /// Позиция /// true - удаление прошло удачно, false - удаление не удалось T Remove(int position); - /// /// Получение объекта по позиции /// diff --git a/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/ListGenericObjects.cs b/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/ListGenericObjects.cs index d1c1a2c..0ffdd99 100644 --- a/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/ListGenericObjects.cs +++ b/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/ListGenericObjects.cs @@ -31,7 +31,6 @@ public class ListGenericObjects : ICollectionGenericObjects } } public CollectionType GetCollectionType => CollectionType.List; - /// /// Конструктор /// @@ -86,7 +85,6 @@ public class ListGenericObjects : ICollectionGenericObjects _collection.RemoveAt(position); return obj; } - public IEnumerable GetItems() { for (int i = 0; i < Count; i++) diff --git a/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/MassiveGenericObjects.cs b/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/MassiveGenericObjects.cs index 11d5d8b..d46a053 100644 --- a/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/MassiveGenericObjects.cs +++ b/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/MassiveGenericObjects.cs @@ -39,7 +39,6 @@ public class MassiveGenericObjects : ICollectionGenericObjects } } } - public CollectionType GetCollectionType => CollectionType.Massive; /// @@ -100,15 +99,13 @@ public class MassiveGenericObjects : ICollectionGenericObjects if (position >= _collection.Length || position < 0) { throw new PositionOutOfCollectionException(position); - } - + } if (_collection[position] == null) { _collection[position] = obj; return position; } int index; - for (index = position + 1; index < _collection.Length; ++index) { if (_collection[index] == null) @@ -117,7 +114,6 @@ public class MassiveGenericObjects : ICollectionGenericObjects return position; } } - for (index = position - 1; index >= 0; --index) { if (_collection[index] == null) @@ -128,7 +124,6 @@ public class MassiveGenericObjects : ICollectionGenericObjects } throw new CollectionOverflowException(Count); } - public T Remove(int position) { // TODO проверка позиции @@ -139,7 +134,6 @@ public class MassiveGenericObjects : ICollectionGenericObjects _collection[position] = null; return obj; } - public IEnumerable GetItems() { for (int i = 0; i < _collection.Length; i++) diff --git a/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/StorageCollection.cs b/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/StorageCollection.cs index 37f2af0..56b9166 100644 --- a/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/StorageCollection.cs +++ b/ProjectSeaplane/ProjectSeaplane/CollectionGenericObjects/StorageCollection.cs @@ -13,28 +13,23 @@ public class StorageCollection /// /// Словарь (хранилище) с коллекциями /// - readonly Dictionary> _storages; - + readonly Dictionary> _storages; /// /// Возвращение списка названий коллекций /// - public List Keys => _storages.Keys.ToList(); - + public List Keys => _storages.Keys.ToList(); /// /// Ключевое слово, с которого должен начинаться файл /// private readonly string _collectionKey = "CollectionsStorage"; - /// /// Разделитель для записи ключа и значения элемента словаря /// private readonly string _separatorForKeyValue = "|"; - /// /// Разделитель для записей коллекции данных в файл /// - private readonly string _separatorItems = ";"; - + private readonly string _separatorItems = ";"; /// /// Конструктор /// @@ -71,7 +66,6 @@ public class StorageCollection if (_storages.ContainsKey(collectionInfo)) _storages.Remove(collectionInfo); } - /// /// Доступ к коллекции /// @@ -89,8 +83,7 @@ public class StorageCollection return null; } - } - + } /// /// Сохранение информации по самолетам в хранилище в файл /// diff --git a/ProjectSeaplane/ProjectSeaplane/FormPlaneCollection.cs b/ProjectSeaplane/ProjectSeaplane/FormPlaneCollection.cs index 9c5d5ed..e069647 100644 --- a/ProjectSeaplane/ProjectSeaplane/FormPlaneCollection.cs +++ b/ProjectSeaplane/ProjectSeaplane/FormPlaneCollection.cs @@ -93,8 +93,6 @@ public partial class FormPlaneCollection : Form _logger.LogError("Ошибка: {Message}", ex.Message); } } - - /// /// Удаление объекта /// @@ -106,12 +104,10 @@ public partial class FormPlaneCollection : Form { return; } - if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) { return; } - int pos = Convert.ToInt32(maskedTextBox.Text); try { @@ -128,7 +124,6 @@ public partial class FormPlaneCollection : Form _logger.LogError("Ошибка: {Message}", ex.Message); } } - /// /// Передача объекта в другую форму /// @@ -172,7 +167,6 @@ public partial class FormPlaneCollection : Form MessageBox.Show(ex.Message, "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error); } } - /// /// Перерисовка коллекции /// @@ -187,9 +181,6 @@ public partial class FormPlaneCollection : Form pictureBox.Image = _company.Show(); } - - - /// /// добавление коллекции /// @@ -240,7 +231,6 @@ public partial class FormPlaneCollection : Form } } } - /// /// удаление коллекции /// @@ -297,7 +287,6 @@ public partial class FormPlaneCollection : Form RerfreshListBoxItems(); } - /// /// Обработка нажатия "Сохранение" /// @@ -322,7 +311,6 @@ public partial class FormPlaneCollection : Form } } } - /// /// Обработка нажатия "Загрузка" ///