Compare commits
2 Commits
941cc8140e
...
aeaba7615e
Author | SHA1 | Date | |
---|---|---|---|
aeaba7615e | |||
9c43a295f5 |
@ -35,7 +35,7 @@ additionalColor, boolean crane, boolean containers,int deck, int deckType, int w
|
||||
return;
|
||||
}
|
||||
iDecksDrawing = decks;
|
||||
|
||||
iDecksDrawing.setNumDecks(ship.Deck);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,7 +1,8 @@
|
||||
import java.util.Random;
|
||||
import java.util.ArrayList;
|
||||
public class ShipGenericDop<T extends EntityShip, U extends IDecksDrawing> {
|
||||
private Object[] Ships;
|
||||
private Object[] Decks;
|
||||
private ArrayList<T> Ships;
|
||||
private ArrayList<U> Decks;
|
||||
private int countShips;
|
||||
private int max_countShips;
|
||||
private int countDecks;
|
||||
@ -12,8 +13,8 @@ public class ShipGenericDop<T extends EntityShip, U extends IDecksDrawing> {
|
||||
public ShipGenericDop(int _max_countShips, int _max_countDecks, int pictureWidth, int pictureHeight){
|
||||
max_countShips = _max_countShips;
|
||||
max_countDecks = _max_countDecks;
|
||||
Ships = new Object[max_countShips];
|
||||
Decks = new Object[max_countDecks];
|
||||
Ships = new ArrayList<T>(max_countShips);
|
||||
Decks = new ArrayList<U>(max_countDecks);
|
||||
countShips = 0;
|
||||
countDecks = 0;
|
||||
_pictureWidth = pictureWidth;
|
||||
@ -27,7 +28,7 @@ public class ShipGenericDop<T extends EntityShip, U extends IDecksDrawing> {
|
||||
if (countShips > max_countShips){
|
||||
return false;
|
||||
}
|
||||
Ships[countShips++] = ship;
|
||||
Ships.add(countShips++, ship);
|
||||
return true;
|
||||
}
|
||||
public boolean AddDeck(U deck){
|
||||
@ -37,7 +38,7 @@ public class ShipGenericDop<T extends EntityShip, U extends IDecksDrawing> {
|
||||
if (countDecks > max_countDecks){
|
||||
return false;
|
||||
}
|
||||
Decks[countDecks++] = deck;
|
||||
Decks.add(countDecks++, deck);
|
||||
return true;
|
||||
}
|
||||
public DrawingShip getObjectRandomShip(){
|
||||
@ -46,13 +47,11 @@ public class ShipGenericDop<T extends EntityShip, U extends IDecksDrawing> {
|
||||
}
|
||||
int i = rand.nextInt(countShips);
|
||||
int j = rand.nextInt(countDecks);
|
||||
DrawingShip drawingShip;
|
||||
DrawingContainerShip drawingContainerShip;
|
||||
if(Ships[i] instanceof EntityContainerShip){
|
||||
return new DrawingContainerShip((EntityContainerShip)Ships[i], (IDecksDrawing)Decks[j], _pictureWidth, _pictureHeight);
|
||||
if(Ships.get(i) instanceof EntityContainerShip){
|
||||
return new DrawingContainerShip((EntityContainerShip)Ships.get(i), (IDecksDrawing)Decks.get(j), _pictureWidth, _pictureHeight);
|
||||
}
|
||||
else{
|
||||
return new DrawingShip((EntityShip)Ships[i],_pictureWidth, _pictureHeight);
|
||||
return new DrawingShip((EntityShip)Ships.get(i),_pictureWidth, _pictureHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user