delete Add View.placeShipRandomly (already in Player.java)

This commit is contained in:
Quentin Legot 2021-04-06 10:36:47 +02:00
parent 1fc316b132
commit eddd1940f8
3 changed files with 3 additions and 13 deletions

View File

@ -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)]);
} }
} }

View File

@ -54,7 +54,7 @@ public class Terminal extends View {
} }
} else { } else {
// Random // Random
placeShipRandomly(player); player.placeShipRandomly();
} }

View File

@ -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";