From 1ccff34c27a3aeaec394fe16e416e3533c102130 Mon Sep 17 00:00:00 2001 From: "nikbel2004@outlook.com" Date: Mon, 13 Nov 2023 02:35:19 +0400 Subject: [PATCH] =?UTF-8?q?=D0=93=D0=BE=D1=82=D0=BE=D0=B2=D0=B0=D1=8F=20?= =?UTF-8?q?=D0=BB=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82=D0=BE=D1=80=D0=BD?= =?UTF-8?q?=D0=B0=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=205?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Tank/Tank/SetGeneric.cs | 8 ++++---- Tank/Tank/TanksGenericStorage.cs | 9 +++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Tank/Tank/SetGeneric.cs b/Tank/Tank/SetGeneric.cs index b8c369d..5f5442f 100644 --- a/Tank/Tank/SetGeneric.cs +++ b/Tank/Tank/SetGeneric.cs @@ -24,20 +24,20 @@ namespace Tank } // Добавление объекта в набор - public bool Insert(T car) + public bool Insert(T tank) { - return Insert(car, 0); + return Insert(tank, 0); } // Добавление на конкретную позицию - public bool Insert(T car, int position) + public bool Insert(T tank, int position) { if (position < 0 || position >= _maxCount) return false; if (Count >= _maxCount) return false; - _places.Insert(0, car); + _places.Insert(0, tank); return true; } diff --git a/Tank/Tank/TanksGenericStorage.cs b/Tank/Tank/TanksGenericStorage.cs index a5fac2f..e328aef 100644 --- a/Tank/Tank/TanksGenericStorage.cs +++ b/Tank/Tank/TanksGenericStorage.cs @@ -11,28 +11,37 @@ namespace Tank { internal class TanksGenericStorage { + // Словарь readonly Dictionary> _tankStorages; + + // Возвращение списка названий наборов public List Keys => _tankStorages.Keys.ToList(); private readonly int _pictureWidth; private readonly int _pictureHeight; + + // Конструктор public TanksGenericStorage(int pictureWidth, int pictureHeight) { _tankStorages = new Dictionary>(); _pictureWidth = pictureWidth; _pictureHeight = pictureHeight; } + + // Добавление набора public void AddSet(string name) { if (_tankStorages.ContainsKey(name)) return; _tankStorages[name] = new TanksGenericCollection(_pictureWidth, _pictureHeight); } + // Удаление набора public void DelSet(string name) { if (!_tankStorages.ContainsKey(name)) return; _tankStorages.Remove(name); } + // Доступ к набору public TanksGenericCollection? this[string ind] {