2022-11-05 13:19:00 +04:00
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
|
|
|
|
|
public class MapsCollection {
|
|
|
|
|
/// Словарь (хранилище) с картами
|
|
|
|
|
final HashMap<String, MapWithSetLocomotivesGeneric<DrawningObjectLocomotive, AbstractMap>> _mapStorages;
|
2022-11-05 18:49:21 +04:00
|
|
|
|
|
2022-11-05 13:19:00 +04:00
|
|
|
|
/// Возвращение списка названий карт
|
|
|
|
|
public ArrayList<String> keys() {
|
|
|
|
|
return new ArrayList<String>(_mapStorages.keySet());
|
|
|
|
|
}
|
|
|
|
|
/// Ширина окна отрисовки
|
|
|
|
|
private final int _pictureWidth;
|
|
|
|
|
/// Высота окна отрисовки
|
|
|
|
|
private final int _pictureHeight;
|
|
|
|
|
/// Конструктор
|
|
|
|
|
public MapsCollection(int pictureWidth, int pictureHeight)
|
|
|
|
|
{
|
|
|
|
|
_mapStorages = new HashMap<String, MapWithSetLocomotivesGeneric<DrawningObjectLocomotive, AbstractMap>>();
|
|
|
|
|
_pictureWidth = pictureWidth;
|
|
|
|
|
_pictureHeight = pictureHeight;
|
|
|
|
|
}
|
|
|
|
|
/// Добавление карты
|
|
|
|
|
public void AddMap(String name, AbstractMap map)
|
|
|
|
|
{
|
|
|
|
|
// Логика для добавления
|
|
|
|
|
if (!_mapStorages.containsKey(name)) _mapStorages.put(name, new MapWithSetLocomotivesGeneric<DrawningObjectLocomotive, AbstractMap>(_pictureWidth, _pictureHeight, map));
|
|
|
|
|
}
|
|
|
|
|
/// Удаление карты
|
|
|
|
|
public void DelMap(String name)
|
|
|
|
|
{
|
|
|
|
|
// Логика для удаления
|
|
|
|
|
if (_mapStorages.containsKey(name)) _mapStorages.remove(name);
|
|
|
|
|
}
|
|
|
|
|
/// Доступ к парковке
|
|
|
|
|
public MapWithSetLocomotivesGeneric<DrawningObjectLocomotive, AbstractMap> Get(String ind)
|
|
|
|
|
{
|
|
|
|
|
// Логика получения объекта
|
|
|
|
|
if (_mapStorages.containsKey(ind)) return _mapStorages.get(ind);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2022-11-05 18:49:21 +04:00
|
|
|
|
// Доп.индексатор из задания
|
|
|
|
|
public DrawningObjectLocomotive Get (String name, int position) {
|
|
|
|
|
if (_mapStorages.containsKey(name)) return _mapStorages.get(name)._setLocomotives.Get(position);
|
|
|
|
|
else return null;
|
|
|
|
|
}
|
2022-11-05 13:19:00 +04:00
|
|
|
|
}
|