44 lines
1.5 KiB
Java
44 lines
1.5 KiB
Java
|
import java.util.ArrayList;
|
||
|
import java.util.HashMap;
|
||
|
|
||
|
public class MapsCollection {
|
||
|
final HashMap<String, MapWithSetBattleshipsGeneric<DrawningObjectBattleship, AbstractMap>> _mapStorages;
|
||
|
private final int _pictureWidth;
|
||
|
private final int _pictureHeight;
|
||
|
|
||
|
public ArrayList<String> Keys() {
|
||
|
return new ArrayList<String>(_mapStorages.keySet());
|
||
|
}
|
||
|
public MapsCollection(int pictureWidth, int pictureHeight)
|
||
|
{
|
||
|
_mapStorages = new HashMap<String, MapWithSetBattleshipsGeneric<DrawningObjectBattleship, AbstractMap>>();
|
||
|
_pictureWidth = pictureWidth;
|
||
|
_pictureHeight = pictureHeight;
|
||
|
}
|
||
|
public void AddMap(String name, AbstractMap map)
|
||
|
{
|
||
|
if (!_mapStorages.containsKey(name))
|
||
|
{
|
||
|
|
||
|
_mapStorages.put(name, new MapWithSetBattleshipsGeneric<DrawningObjectBattleship, AbstractMap>(_pictureWidth, _pictureHeight, map));
|
||
|
|
||
|
}
|
||
|
// TODO Прописать логику для добавления
|
||
|
}
|
||
|
public void DelMap(String name)
|
||
|
{
|
||
|
if (_mapStorages.containsKey(name)) { _mapStorages.remove(name); }
|
||
|
}
|
||
|
public MapWithSetBattleshipsGeneric<DrawningObjectBattleship, AbstractMap> Get(String ind)
|
||
|
{
|
||
|
if (_mapStorages.containsKey(ind)) return _mapStorages.get(ind);
|
||
|
return null;
|
||
|
}
|
||
|
public DrawningObjectBattleship Get(String name, int pos)
|
||
|
{
|
||
|
if (_mapStorages.containsKey(name)) return _mapStorages.get(name)._setBattleship.Get(pos);
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
}
|