delete Add View.placeShipRandomly (already in Player.java)
This commit is contained in:
parent
1fc316b132
commit
eddd1940f8
@ -92,11 +92,11 @@ public abstract class Player {
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void placeShipRandomly(Player player) {
|
public void placeShipRandomly() {
|
||||||
Random rand = new Random();
|
Random rand = new Random();
|
||||||
for(int i : bato) {
|
for(int i : bato) {
|
||||||
Ship ship = null;
|
Ship ship = null;
|
||||||
while(ship == null || !player.setShips(ship)) {
|
while(ship == null || !setShips(ship)) {
|
||||||
ship = new Ship(new Pair<>(rand.nextInt(10), rand.nextInt(10)), i, Direction.values()[rand.nextInt(Direction.values().length)]);
|
ship = new Ship(new Pair<>(rand.nextInt(10), rand.nextInt(10)), i, Direction.values()[rand.nextInt(Direction.values().length)]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ public class Terminal extends View {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Random
|
// Random
|
||||||
placeShipRandomly(player);
|
player.placeShipRandomly();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,16 +25,6 @@ public abstract class View {
|
|||||||
|
|
||||||
public abstract void displayBoard();
|
public abstract void displayBoard();
|
||||||
|
|
||||||
public void placeShipRandomly(Player player) {
|
|
||||||
Random rand = new Random();
|
|
||||||
for(int i : ships) {
|
|
||||||
Ship ship = null;
|
|
||||||
while(ship == null || !player.setShips(ship)) {
|
|
||||||
ship = new Ship(new Pair<>(rand.nextInt(10), rand.nextInt(10)), i, Direction.values()[rand.nextInt(Direction.values().length)]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
// String chain = "A vous de joueur "+game.currentPlayer.toString()+ "\n+ - - - - - - - - - - +\n";
|
// String chain = "A vous de joueur "+game.currentPlayer.toString()+ "\n+ - - - - - - - - - - +\n";
|
||||||
|
Loading…
Reference in New Issue
Block a user