From 29a63c996b306c7e62d08e153d7e1e8125674c22 Mon Sep 17 00:00:00 2001 From: the Date: Tue, 11 Oct 2022 11:28:14 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9A=D0=BE=D0=BB=D0=BB=D0=B5=D0=BA=D1=86?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=BA=D0=B0=D1=80=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ship/Ship/MapsCollection.cs | 71 +++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 Ship/Ship/MapsCollection.cs diff --git a/Ship/Ship/MapsCollection.cs b/Ship/Ship/MapsCollection.cs new file mode 100644 index 0000000..4042a88 --- /dev/null +++ b/Ship/Ship/MapsCollection.cs @@ -0,0 +1,71 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Ship +{ + /// + /// Класс для хранения коллекции карт + /// + internal class MapsCollection + { + /// + /// Словарь (хранилище) с картами + /// + readonly Dictionary> _mapStorages; + /// + /// Возвращение списка названий карт + /// + public List Keys => _mapStorages.Keys.ToList(); + /// /// Ширина окна отрисовки + /// + private readonly int _pictureWidth; + /// + /// Высота окна отрисовки + /// + private readonly int _pictureHeight; + /// + /// Конструктор + /// + /// + /// + public MapsCollection(int pictureWidth, int pictureHeight) + { + _mapStorages = new Dictionary>(); + _pictureWidth = pictureWidth; + _pictureHeight = pictureHeight; + } + /// + /// Добавление карты + /// + /// Название карты + /// Карта + public void AddMap(string name, AbstractMap map) + { + _mapStorages.Add(name, new MapWithSetShipsGeneric(_pictureWidth, _pictureHeight, map)); + } + /// + /// Удаление карты + /// + /// Название карты + public void DelMap(string name) + { + _mapStorages.Remove(name); + } + /// + /// Доступ к парковке + /// + /// + /// + public MapWithSetShipsGeneric this[string ind] + { + get + { + if (_mapStorages.ContainsKey(ind)) return _mapStorages[ind]; + else return null; + } + } + } +}