PIbd-23_Minhasapov_R.H._Exc.../MapsCollection.java

34 lines
1005 B
Java

import java.util.HashMap;
import java.util.Set;
public class MapsCollection {
private final HashMap<String, MapWithSetTracktorGeneric<DrawningObjectExcavator, AbstractMap>> _mapsStorage;
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 MapWithSetTracktorGeneric<>(_pictureWidth, _pictureHeight, map));
}
}
public void deleteMap(String name) {
_mapsStorage.remove(name);
}
public MapWithSetTracktorGeneric<DrawningObjectExcavator, AbstractMap> getMap(String name) {
return _mapsStorage.getOrDefault(name, null);
}
}