diff --git a/src/main/java/MapsCollection.java b/src/main/java/MapsCollection.java new file mode 100644 index 0000000..3efab5a --- /dev/null +++ b/src/main/java/MapsCollection.java @@ -0,0 +1,46 @@ +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Set; + +public class MapsCollection { + public HashMap> _mapStorages; + private int _pictureWidth; + private int _pictureHeight; + + public MapsCollection(int pictureWidth, int pictureHeight) + { + _mapStorages = new HashMap<>(); + _pictureWidth = pictureWidth; + _pictureHeight = pictureHeight; + } + + public Set getKeys() { + return _mapStorages.keySet(); + } + + public void AddMap(String name, AbstractMap map) + { + if (!getKeys().contains(name)) + _mapStorages.put(name, new MapWithSetArmoredCarsGeneric<>(_pictureWidth, _pictureHeight, map)); + } + + public void DelMap(String name) + { + if (getKeys().contains(name)) + _mapStorages.remove(name); + } + + public MapWithSetArmoredCarsGeneric get(String ind) + { + if (getKeys().contains(ind)) + return _mapStorages.get(ind); + return null; + } + // дополнительное задание: метод "индексатор" с двумя параметрами + public IDrawingObject get(String ind1, int pos) { + if (_mapStorages.containsKey(ind1)) + return _mapStorages.get(ind1).get_setCars().Get(pos); + return null; + } +}