54 lines
1.5 KiB
Java

package ProjectElectricLocomotive;
import java.util.HashMap;
import java.util.List;
public class LocomotivesGenericStorage {
final HashMap<String, LocomotiveGenericCollection<DrawingLocomotive, DrawingObjectLocomotive>> _locomotiveStorage;
public List<String> Keys()
{
return _locomotiveStorage.keySet().stream().toList();
}
private final int _pictureWidth;
private final int _pictureHeight;
public LocomotivesGenericStorage(int pictureWidth, int pictureHeight) {
_locomotiveStorage = new HashMap<>();
_pictureWidth = pictureWidth;
_pictureHeight = pictureHeight;
}
public void AddSet(String name)
{
if (!(_locomotiveStorage.containsKey(name)))
{
_locomotiveStorage.put(name, new LocomotiveGenericCollection<DrawingLocomotive, DrawingObjectLocomotive>(_pictureWidth, _pictureHeight));
}
}
public void DelSet(String name)
{
if (_locomotiveStorage.keySet().contains(name))
{
_locomotiveStorage.remove(name);
}
}
public LocomotiveGenericCollection<DrawingLocomotive, DrawingObjectLocomotive> get(String ind)
{
if (_locomotiveStorage.keySet().contains(ind))
{
return _locomotiveStorage.get(ind);
}
return null;
}
public DrawingObjectLocomotive get(String name, int ind)
{
if (_locomotiveStorage.keySet().contains(ind))
{
return _locomotiveStorage.get(name).GetU(ind);
}
return null;
}
}