PIbd-23_Polevoy_S.V._SelfPr.../MapsCollection.java

42 lines
1.2 KiB
Java
Raw Normal View History

2022-11-05 16:40:00 +04:00
import java.util.HashMap;
import java.util.Set;
public class MapsCollection {
2022-11-05 19:18:29 +04:00
private final HashMap<String, MapWithSetArtilleriesGeneric<IDrawingObject, AbstractMap>> _mapsStorage;
2022-11-05 16:40:00 +04:00
private final int _pictureWidth;
private final int _pictureHeight;
public Set<String> getKeys() {
return _mapsStorage.keySet();
}
public MapsCollection(int pictureWidth, int pictureHeight) {
_mapsStorage = new HashMap<>();
_pictureWidth = pictureWidth;
_pictureHeight = pictureHeight;
}
public void addMap(String name, AbstractMap map) {
if (!_mapsStorage.containsKey(name)) {
_mapsStorage.put(name, new MapWithSetArtilleriesGeneric<>(_pictureWidth, _pictureHeight, map));
}
}
public void deleteMap(String name) {
_mapsStorage.remove(name);
}
2022-11-05 19:18:29 +04:00
public MapWithSetArtilleriesGeneric<IDrawingObject, AbstractMap> getMap(String name) {
2022-11-05 16:40:00 +04:00
return _mapsStorage.getOrDefault(name, null);
}
2022-11-08 16:19:52 +04:00
public IDrawingObject getArtillery(String mapName, int index) {
var map = _mapsStorage.getOrDefault(mapName, null);
if (map != null) {
return map._setArtilleries.get(index);
}
return null;
}
2022-11-05 16:40:00 +04:00
}