Eliseev E.E. LabWork04 #4

Closed
ElEgEv wants to merge 14 commits from LabWork04 into LabWork03
2 changed files with 29 additions and 2 deletions
Showing only changes of commit f96d26add6 - Show all commits

View File

@ -1,5 +1,6 @@
import java.awt.*;
import java.awt.image.BufferedImage;
import java.util.LinkedList;
public class MapWithSetPlanesGeneric <T extends IDrawningObject, U extends AbstractMap>
{
@ -18,6 +19,9 @@ public class MapWithSetPlanesGeneric <T extends IDrawningObject, U extends Abstr
//набор объектов
private final SetPlanesGeneric<T> _setPlanes;
//набор удалённых объектов
public final LinkedList<T> _deletePlane;
//карта
private final U _map;
@ -27,6 +31,7 @@ public class MapWithSetPlanesGeneric <T extends IDrawningObject, U extends Abstr
int width = picWidth / _placeSizeWidth;
int height = picHeight / _placeSizeHeight;
_setPlanes = new SetPlanesGeneric<T>(width * height);
_deletePlane = new LinkedList<>();
_pictureWidth = picWidth;
_pictureHeight = picHeight;
_map = map;
@ -39,6 +44,8 @@ public class MapWithSetPlanesGeneric <T extends IDrawningObject, U extends Abstr
public T Delete(int position)
{
_deletePlane.add(_setPlanes.Get(position));
return _setPlanes.Remove(position);
}
@ -205,8 +212,18 @@ public class MapWithSetPlanesGeneric <T extends IDrawningObject, U extends Abstr
}
}
public MapWithSetPlanesGeneric<T,U> GetPlaneInList(int index)
public T GetPlaneInList(int index)
{
return _setPlanes.Get(index);
}
public T GetTractorInDelete()
{
if(_deletePlane.isEmpty())
{
return null;
}
return _deletePlane.pop();
}
}

View File

@ -42,7 +42,17 @@ public class MapsCollection
}
//Доступ к аэродрому
public MapWithSetPlanesGeneric<DrawningObjectPlane, AbstractMap> Get(String name, int index)
public MapWithSetPlanesGeneric<DrawningObjectPlane, AbstractMap> get(String index)
{
if(_mapStorage.containsKey(index))
{
return _mapStorage.get(index);
}
return null;
}
public DrawningObjectPlane Get(String name, int index)
{
if(_mapStorage.containsKey(name))
{