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;
|
return;
|
||||||
}
|
}
|
||||||
iDecksDrawing = decks;
|
iDecksDrawing = decks;
|
||||||
|
iDecksDrawing.setNumDecks(ship.Deck);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
import java.util.ArrayList;
|
||||||
public class ShipGenericDop<T extends EntityShip, U extends IDecksDrawing> {
|
public class ShipGenericDop<T extends EntityShip, U extends IDecksDrawing> {
|
||||||
private Object[] Ships;
|
private ArrayList<T> Ships;
|
||||||
private Object[] Decks;
|
private ArrayList<U> Decks;
|
||||||
private int countShips;
|
private int countShips;
|
||||||
private int max_countShips;
|
private int max_countShips;
|
||||||
private int countDecks;
|
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){
|
public ShipGenericDop(int _max_countShips, int _max_countDecks, int pictureWidth, int pictureHeight){
|
||||||
max_countShips = _max_countShips;
|
max_countShips = _max_countShips;
|
||||||
max_countDecks = _max_countDecks;
|
max_countDecks = _max_countDecks;
|
||||||
Ships = new Object[max_countShips];
|
Ships = new ArrayList<T>(max_countShips);
|
||||||
Decks = new Object[max_countDecks];
|
Decks = new ArrayList<U>(max_countDecks);
|
||||||
countShips = 0;
|
countShips = 0;
|
||||||
countDecks = 0;
|
countDecks = 0;
|
||||||
_pictureWidth = pictureWidth;
|
_pictureWidth = pictureWidth;
|
||||||
@ -27,7 +28,7 @@ public class ShipGenericDop<T extends EntityShip, U extends IDecksDrawing> {
|
|||||||
if (countShips > max_countShips){
|
if (countShips > max_countShips){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Ships[countShips++] = ship;
|
Ships.add(countShips++, ship);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public boolean AddDeck(U deck){
|
public boolean AddDeck(U deck){
|
||||||
@ -37,7 +38,7 @@ public class ShipGenericDop<T extends EntityShip, U extends IDecksDrawing> {
|
|||||||
if (countDecks > max_countDecks){
|
if (countDecks > max_countDecks){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Decks[countDecks++] = deck;
|
Decks.add(countDecks++, deck);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public DrawingShip getObjectRandomShip(){
|
public DrawingShip getObjectRandomShip(){
|
||||||
@ -46,13 +47,11 @@ public class ShipGenericDop<T extends EntityShip, U extends IDecksDrawing> {
|
|||||||
}
|
}
|
||||||
int i = rand.nextInt(countShips);
|
int i = rand.nextInt(countShips);
|
||||||
int j = rand.nextInt(countDecks);
|
int j = rand.nextInt(countDecks);
|
||||||
DrawingShip drawingShip;
|
if(Ships.get(i) instanceof EntityContainerShip){
|
||||||
DrawingContainerShip drawingContainerShip;
|
return new DrawingContainerShip((EntityContainerShip)Ships.get(i), (IDecksDrawing)Decks.get(j), _pictureWidth, _pictureHeight);
|
||||||
if(Ships[i] instanceof EntityContainerShip){
|
|
||||||
return new DrawingContainerShip((EntityContainerShip)Ships[i], (IDecksDrawing)Decks[j], _pictureWidth, _pictureHeight);
|
|
||||||
}
|
}
|
||||||
else{
|
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