From 8d7bf2159a97d8c785787371ce0c09f3b84bcb50 Mon Sep 17 00:00:00 2001 From: bulatova_karina Date: Sat, 2 Dec 2023 20:53:19 +0300 Subject: [PATCH] fixed 4 --- WarmlyShip/WarmlyShip/SetGeneric.cs | 41 ++------------- .../WarmlyShip/ShipsGenericCollection.cs | 50 ------------------- WarmlyShip/WarmlyShip/ShipsGenericStorage.cs | 30 ----------- 3 files changed, 3 insertions(+), 118 deletions(-) diff --git a/WarmlyShip/WarmlyShip/SetGeneric.cs b/WarmlyShip/WarmlyShip/SetGeneric.cs index 4c31c0a..7a0d008 100644 --- a/WarmlyShip/WarmlyShip/SetGeneric.cs +++ b/WarmlyShip/WarmlyShip/SetGeneric.cs @@ -9,32 +9,14 @@ namespace WarmlyShip.Generics internal class SetGeneric where T : class { - /// - /// Список объектов, которые храним - /// private readonly List _places; - /// - /// Количество объектов в списке - /// public int Count => _places.Count; - /// - /// Максимальное количество объектов в списке - /// private readonly int _maxCount; - /// - /// Конструктор - /// - /// public SetGeneric(int count) { _maxCount = count; _places = new List(count); } - /// - /// Добавление объекта в набор - /// - /// Добавляемый теплоход - /// public bool Insert(T warmlyship) { if (_places.Count == _maxCount) @@ -44,12 +26,7 @@ namespace WarmlyShip.Generics Insert(warmlyship, 0); return true; } - /// - /// Добавление объекта в набор на конкретную позицию - /// - /// Добавляемый теплоход - /// Позиция - /// + public bool Insert(T warmlyship, int position) { if (!(position >= 0 && position <= Count && _places.Count < _maxCount)) @@ -59,11 +36,7 @@ namespace WarmlyShip.Generics _places.Insert(position, warmlyship); return true; } - /// - /// Удаление объекта из набора с конкретной позиции - /// - /// - /// + public bool Remove(int position) { if (position < 0 || position >= Count) @@ -73,11 +46,7 @@ namespace WarmlyShip.Generics _places.RemoveAt(position); return true; } - /// - /// Получение объекта из набора по позиции - /// - /// - /// + public T? this[int position] { get @@ -99,10 +68,6 @@ namespace WarmlyShip.Generics return; } } - /// - /// Проход по списку - /// - /// public IEnumerable GetShips(int? maxShips = null) { for (int i = 0; i < _places.Count; ++i) diff --git a/WarmlyShip/WarmlyShip/ShipsGenericCollection.cs b/WarmlyShip/WarmlyShip/ShipsGenericCollection.cs index 55af291..b902983 100644 --- a/WarmlyShip/WarmlyShip/ShipsGenericCollection.cs +++ b/WarmlyShip/WarmlyShip/ShipsGenericCollection.cs @@ -6,7 +6,6 @@ using System.Threading.Tasks; using WarmlyShip.DrawingObjects; using WarmlyShip.MovementStrategy; -using static System.Windows.Forms.VisualStyles.VisualStyleElement; namespace WarmlyShip.Generics { @@ -14,31 +13,11 @@ namespace WarmlyShip.Generics where T : DrawingWarmlyShip where U : IMoveableObject { - /// - /// Ширина окна прорисовки - /// private readonly int _pictureWidth; - /// - /// Высота окна прорисовки - /// private readonly int _pictureHeight; - /// - /// Размер занимаемого объектом места (ширина) - /// private readonly int _placeSizeWidth = 185; - /// - /// Размер занимаемого объектом места (высота) - /// private readonly int _placeSizeHeight = 185; - /// - /// Набор объектов - /// private readonly SetGeneric _collection; - /// - /// Конструктор - /// - /// - /// public ShipsGenericCollection(int picWidth, int picHeight) { int width = picWidth / _placeSizeWidth; @@ -47,12 +26,6 @@ namespace WarmlyShip.Generics _pictureHeight = picHeight; _collection = new SetGeneric(width * height); } - /// - /// Перегрузка оператора сложения - /// - /// - /// - /// public static bool operator +(ShipsGenericCollection collect, T? obj) { @@ -62,12 +35,6 @@ namespace WarmlyShip.Generics } return (bool)collect?._collection.Insert(obj); } - /// - /// Перегрузка оператора вычитания - /// - /// - /// - /// public static T? operator -(ShipsGenericCollection collect, int pos) { @@ -78,19 +45,10 @@ namespace WarmlyShip.Generics } return obj; } - /// - /// Получение объекта IMoveableObject - /// - /// - /// public U? GetU(int pos) { return (U?)_collection[pos]?.GetMoveableObject; } - /// - /// Вывод всего набора объектов - /// - /// public Bitmap ShowShips() { Bitmap bmp = new(_pictureWidth, _pictureHeight); @@ -99,10 +57,6 @@ namespace WarmlyShip.Generics DrawObjects(gr); return bmp; } - /// - /// Метод отрисовки фона - /// - /// private void DrawBackground(Graphics g) { Pen pen = new(Color.Black, 3); @@ -119,10 +73,6 @@ namespace WarmlyShip.Generics _placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight); } } - /// - /// /// Метод прорисовки объектов - /// - /// private void DrawObjects(Graphics g) { int i = 0; diff --git a/WarmlyShip/WarmlyShip/ShipsGenericStorage.cs b/WarmlyShip/WarmlyShip/ShipsGenericStorage.cs index 8e6c2e8..dac498d 100644 --- a/WarmlyShip/WarmlyShip/ShipsGenericStorage.cs +++ b/WarmlyShip/WarmlyShip/ShipsGenericStorage.cs @@ -10,27 +10,10 @@ namespace WarmlyShip.Generics { internal class ShipsGenericStorage { - /// - /// Словарь (хранилище) - /// readonly Dictionary> _shipStorages; - /// - /// Возвращение списка названий наборов - /// public List Keys => _shipStorages.Keys.ToList(); - /// - /// Ширина окна отрисовки - /// private readonly int _pictureWidth; - /// - /// Высота окна отрисовки - /// private readonly int _pictureHeight; - /// - /// Конструктор - /// - /// - /// /// public ShipsGenericStorage(int pictureWidth, int pictureHeight) { _shipStorages = new Dictionary - /// Добавление набора - /// - /// Название набора public void AddSet(string name) { if (_shipStorages.ContainsKey(name)) @@ -50,10 +29,6 @@ namespace WarmlyShip.Generics } _shipStorages[name] = new ShipsGenericCollection(_pictureWidth, _pictureHeight); } - /// - /// Удаление набора - /// - /// Название набора public void DelSet(string name) { if (!_shipStorages.ContainsKey(name)) @@ -63,11 +38,6 @@ namespace WarmlyShip.Generics _shipStorages.Remove(name); } - /// - /// Доступ к набору - /// - /// - /// public ShipsGenericCollection? this[string ind] { get