Добавлен класс MapsCollection
This commit is contained in:
parent
8aa6989be2
commit
0b528dee91
46
src/main/java/MapsCollection.java
Normal file
46
src/main/java/MapsCollection.java
Normal file
@ -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<String, MapWithSetArmoredCarsGeneric<IDrawingObject, AbstractMap>> _mapStorages;
|
||||
private int _pictureWidth;
|
||||
private int _pictureHeight;
|
||||
|
||||
public MapsCollection(int pictureWidth, int pictureHeight)
|
||||
{
|
||||
_mapStorages = new HashMap<>();
|
||||
_pictureWidth = pictureWidth;
|
||||
_pictureHeight = pictureHeight;
|
||||
}
|
||||
|
||||
public Set<String> 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<IDrawingObject, AbstractMap> 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;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user