From 6c787200aa09200f5ca0720d6c481757710ebfc9 Mon Sep 17 00:00:00 2001 From: ksenianeva <95441235+ksenianeva@users.noreply.github.com> Date: Tue, 1 Nov 2022 12:29:58 +0400 Subject: [PATCH] =?UTF-8?q?=D0=AD=D1=82=D0=B0=D0=BF=202.=20=D0=9A=D0=BB?= =?UTF-8?q?=D0=B0=D1=81=D1=81=20MapsCollection.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ContainerShip/ContainerShip/MapsCollection.cs | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 ContainerShip/ContainerShip/MapsCollection.cs diff --git a/ContainerShip/ContainerShip/MapsCollection.cs b/ContainerShip/ContainerShip/MapsCollection.cs new file mode 100644 index 0000000..d1c9b62 --- /dev/null +++ b/ContainerShip/ContainerShip/MapsCollection.cs @@ -0,0 +1,80 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ContainerShip +{ + 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) + { + // TODO Прописать логику для добавления + if (_mapStorages.ContainsKey(name)) return; + else + { + _mapStorages.Add(name, new MapWithSetShipsGeneric(_pictureWidth, _pictureHeight, map)); + } + + } + /// + /// Удаление карты + /// + /// Название карты + public void DelMap(string name) + { + // TODO Прописать логику для удаления + if (_mapStorages.ContainsKey(name)) + { + _mapStorages.Remove(name); + } + } + /// + /// Доступ к парковке + /// + /// + /// + public MapWithSetShipsGeneric this[string ind] + { + get + { + //TODO логика получения объекта + if (_mapStorages.ContainsKey(ind)) return _mapStorages[ind]; + return null; + } + } + } +}