diff --git a/src/battleship/model/player/Player.java b/src/battleship/model/player/Player.java index fab9ec6..33789be 100644 --- a/src/battleship/model/player/Player.java +++ b/src/battleship/model/player/Player.java @@ -92,11 +92,11 @@ public abstract class Player { return id; } - public void placeShipRandomly(Player player) { + public void placeShipRandomly() { Random rand = new Random(); for(int i : bato) { 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)]); } } diff --git a/src/battleship/view/Terminal.java b/src/battleship/view/Terminal.java index 96f6554..38eb3bb 100644 --- a/src/battleship/view/Terminal.java +++ b/src/battleship/view/Terminal.java @@ -54,7 +54,7 @@ public class Terminal extends View { } } else { // Random - placeShipRandomly(player); + player.placeShipRandomly(); } diff --git a/src/battleship/view/View.java b/src/battleship/view/View.java index c232910..263b05e 100644 --- a/src/battleship/view/View.java +++ b/src/battleship/view/View.java @@ -25,16 +25,6 @@ public abstract class View { 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 public String toString() { // String chain = "A vous de joueur "+game.currentPlayer.toString()+ "\n+ - - - - - - - - - - +\n";