package ProjectStormtrooper; import java.util.ArrayList; import java.util.Random; public class DoubleParametrized { ArrayList _entityPlanes; ArrayList _drawingEngines; public DoubleParametrized() { _entityPlanes = new ArrayList<>(); _drawingEngines = new ArrayList<>(); } public void Add(T entityPlaneObject) { _entityPlanes.add(entityPlaneObject); } public void Add(U drawingEnginesObject) { _drawingEngines.add(drawingEnginesObject); } public DrawingPlane GeneratePlane(int pictureWidth, int pictureHeight) { Random random = new Random(); if (_entityPlanes.isEmpty()) { return null; } T entityPlane = _entityPlanes.get(random.nextInt(_entityPlanes.size())); U drawingEngine = null; if (!_drawingEngines.isEmpty()) { drawingEngine = _drawingEngines.get(random.nextInt(_drawingEngines.size())); } DrawingPlane drawingPlane; if (entityPlane instanceof EntityStormtrooper) { drawingPlane = new DrawingStormtrooper((EntityStormtrooper) entityPlane, drawingEngine, pictureWidth, pictureHeight); } else { drawingPlane = new DrawingPlane(entityPlane, drawingEngine, pictureWidth, pictureHeight); } return drawingPlane; } }