PIbd-23. Zakharov R.A. Lab work 03 #4

Closed
Zakharov_Rostislav wants to merge 7 commits from Lab3 into Lab2
Showing only changes of commit 766efc216d - Show all commits

View File

@ -12,15 +12,15 @@ public class HardGeneric<T extends EntityShip, U extends IDrawBlocks>{
U[] blocks;
private int shipsNumber;
private int blocksNumber;
private final int pictureBoxWidth;
private final int pictureBoxHeight;
private final int PICTURE_WIDTH;
private final int PICTURE_HEIGHT;
public HardGeneric(int shipsCount, int blocksCount, int width, int height){
shipsNumber = 0;
blocksNumber = 0;
ships = (T[]) new EntityShip[shipsCount];
blocks = (U[]) new IDrawBlocks[blocksCount];
pictureBoxHeight = height;
pictureBoxWidth = width;
PICTURE_HEIGHT = height;
PICTURE_WIDTH = width;
}
public boolean insertShip(T entityShip){
Review

Методы добавления должны быть полиморфными

Методы добавления должны быть полиморфными
if(ships[ships.length-1] != null)
@ -48,8 +48,8 @@ public class HardGeneric<T extends EntityShip, U extends IDrawBlocks>{
IDrawBlocks block = blocks[rand.nextInt(0, blocksNumber)];
if (entity instanceof EntityBattleship)
return new DrawingBattleship(entity.getSpeed(), entity.getWeight(), entity.getBodyColor(), ((EntityBattleship) entity).getAdditionalColor(),
((EntityBattleship) entity).getTurret(), ((EntityBattleship) entity).getRocketLauncher(), pictureBoxWidth, pictureBoxHeight, block.getType(), block.getNumber());
return new DrawingShip(entity.getSpeed(), entity.getWeight(), entity.getBodyColor(), pictureBoxWidth, pictureBoxHeight, block.getType(), block.getNumber());
((EntityBattleship) entity).getTurret(), ((EntityBattleship) entity).getRocketLauncher(), PICTURE_WIDTH, PICTURE_HEIGHT, block.getType(), block.getNumber());
return new DrawingShip(entity.getSpeed(), entity.getWeight(), entity.getBodyColor(), PICTURE_WIDTH, PICTURE_HEIGHT, block.getType(), block.getNumber());
}
public EntityShip makeRandomShip(){
Random random = new Random();