From ee384c3f2b1155288f131323f389c1dabcf0258f Mon Sep 17 00:00:00 2001 From: Danila_Mochalov Date: Sat, 5 Nov 2022 13:19:00 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A5=D1=83=D0=B4=D0=BE-=D0=B1=D0=B5=D0=B4?= =?UTF-8?q?=D0=BD=D0=BE=20=D1=81=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=20=D0=BA?= =?UTF-8?q?=D0=BB=D0=B0=D1=81=D1=81=20MapsCollection?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MapsCollection.java | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 MapsCollection.java diff --git a/MapsCollection.java b/MapsCollection.java new file mode 100644 index 0000000..a6428f4 --- /dev/null +++ b/MapsCollection.java @@ -0,0 +1,41 @@ +import java.util.ArrayList; +import java.util.HashMap; + +public class MapsCollection { + /// Словарь (хранилище) с картами + final HashMap> _mapStorages; + /// Возвращение списка названий карт + public ArrayList keys() { + return new ArrayList(_mapStorages.keySet()); + } + /// Ширина окна отрисовки + private final int _pictureWidth; + /// Высота окна отрисовки + private final int _pictureHeight; + /// Конструктор + public MapsCollection(int pictureWidth, int pictureHeight) + { + _mapStorages = new HashMap>(); + _pictureWidth = pictureWidth; + _pictureHeight = pictureHeight; + } + /// Добавление карты + public void AddMap(String name, AbstractMap map) + { + // Логика для добавления + if (!_mapStorages.containsKey(name)) _mapStorages.put(name, new MapWithSetLocomotivesGeneric(_pictureWidth, _pictureHeight, map)); + } + /// Удаление карты + public void DelMap(String name) + { + // Логика для удаления + if (_mapStorages.containsKey(name)) _mapStorages.remove(name); + } + /// Доступ к парковке + public MapWithSetLocomotivesGeneric Get(String ind) + { + // Логика получения объекта + if (_mapStorages.containsKey(ind)) return _mapStorages.get(ind); + return null; + } +}