87 lines
2.7 KiB
Java
87 lines
2.7 KiB
Java
import java.util.Dictionary;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.stream.Collectors;
|
|
|
|
public class ShipGenericStorage {
|
|
HashMap<String, ShipGenericCollection<DrawingShip,
|
|
DrawningObjectShip>> _shipStorages;
|
|
/// <summary>
|
|
/// Возвращение списка названий наборов
|
|
/// </summary>
|
|
public List<String> Keys() {return _shipStorages.keySet().stream().collect(Collectors.toList());}
|
|
/// <summary>
|
|
/// Ширина окна отрисовки
|
|
/// </summary>
|
|
private int _pictureWidth;
|
|
/// <summary>
|
|
/// Высота окна отрисовки
|
|
/// </summary>
|
|
private int _pictureHeight;
|
|
/// <summary>
|
|
/// Конструктор
|
|
/// </summary>
|
|
/// <param name="pictureWidth"></param>
|
|
/// <param name="pictureHeight"></param>
|
|
public ShipGenericStorage(int pictureWidth, int pictureHeight)
|
|
{
|
|
_shipStorages = new HashMap<String, ShipGenericCollection<DrawingShip,DrawningObjectShip>>();
|
|
_pictureWidth = pictureWidth;
|
|
_pictureHeight = pictureHeight;
|
|
}
|
|
/// <summary>
|
|
/// Добавление набора
|
|
/// </summary>
|
|
/// <param name="name">Название набора</param>
|
|
public void AddSet(String name)
|
|
{
|
|
|
|
if (_shipStorages.containsKey(name))
|
|
{
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
_shipStorages.put(name, new ShipGenericCollection<DrawingShip, DrawningObjectShip>(_pictureWidth, _pictureHeight));
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Удаление набора
|
|
/// </summary>
|
|
/// <param name="name">Название набора</param>
|
|
public void DelSet(String name)
|
|
{
|
|
if (!_shipStorages.containsKey(name))
|
|
{
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
_shipStorages.remove(name);
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// Доступ к набору
|
|
/// </summary>
|
|
/// <param name="ind"></param>
|
|
/// <returns></returns>
|
|
public ShipGenericCollection<DrawingShip, DrawningObjectShip> get(String ind)
|
|
{
|
|
if (_shipStorages.containsKey(ind))
|
|
{
|
|
return _shipStorages.get(ind);
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
public DrawningObjectShip get(String ind1, int ind2){
|
|
if (!_shipStorages.containsKey(ind1))
|
|
return null;
|
|
return _shipStorages.get(ind1).GetU(ind2);
|
|
}
|
|
|
|
}
|