package pw.scho.battleship.model;

import java.util.ArrayList;
import java.util.List;

public class Board {

    public static final int WIDTH = 10;
    public static final int HEIGHT = 10;
    private Ship[][] ships2DMap = new Ship[HEIGHT][WIDTH];
    private boolean[][] shots2DMap = new boolean[HEIGHT][WIDTH];
    private final BoardMessageQueue messageQueue = new BoardMessageQueue();
    private List<Ship> ships = new ArrayList();
    private List<Position> shots = new ArrayList();

    public BoardMessageQueue getMessageQueue() {
        return messageQueue;
    }

    public List<Ship> getShips() {
        return ships;
    }

    public List<Position> getShots() {
        return shots;
    }

    public boolean shipIsPlaceable(Ship ship) {
        for (Position position : ship.getShipPositions()) {
            if (!positionIsOnBoard(position) || positionIsTaken(position)) {
                return false;
            }
        }

        for (Position position : ship.getBoarderPositions()) {
            if (positionIsOnBoard(position) && positionIsTaken(position)) {
                return false;
            }
        }

        return true;
    }

    public void placeShip(Ship ship) {
        if (!shipIsPlaceable(ship)) {
            throw GameException.CreateShipNotPlaceable();
        }

        for (Position position : ship.getShipPositions()) {
            setShipAtPosition(ship, position);
        }
        ships.add(ship);
    }

    public boolean isShootableAt(Position position) {
        return shots2DMap[position.getY()][position.getX()] == false;
    }

    public void shootAt(Position position) {
        if (!isShootableAt(position)) {
            throw GameException.CreateAlreadyShotAt();
        }

        shots2DMap[position.getY()][position.getX()] = true;
        Ship ship = getShipAtPosition(position);

        shots.add(position);

        if (ship != null) {
            ship.hit();
            messageQueue.addHitMessage(position, ship);
        } else {
            messageQueue.addMissMessage(position);
        }
    }

    public boolean allShipsSunk() {
        for (Ship ship : ships) {
            if (!ship.sunk()) {
                return false;
            }
        }
        return true;
    }

    public void resetAndPlayThrough() {
        shots2DMap = new boolean[HEIGHT][WIDTH];
        shots2DMap = new boolean[HEIGHT][WIDTH];

        List<Ship> copiedShips = new ArrayList(ships);
        for (Ship ship : copiedShips) {
            ship.reset();
        }

        List<Position> copiedShots = new ArrayList(shots);

        ships.clear();
        shots.clear();

        for (Ship ship : copiedShips) {
            placeShip(ship);
        }
        for (Position position : copiedShots) {
            shootAt(position);
        }
    }

    private boolean positionIsTaken(Position position) {
        return getShipAtPosition(position) != null;
    }

    private Ship getShipAtPosition(Position position) {
        return ships2DMap[position.getY()][position.getX()];
    }

    private void setShipAtPosition(Ship ship, Position position) {
        ships2DMap[position.getY()][position.getX()] = ship;
    }

    private boolean positionIsOnBoard(Position position) {
        return position.getX() >= 0 &&
                position.getY() >= 0 &&
                position.getX() < WIDTH &&
                position.getY() < HEIGHT;
    }
}

@@ -2409,79 +2409,55 @@
     
-List%3CShip%3E copiedShips = new ArrayList(ships);%0A 
+ships.forEach(Ship::reset);%0A%0A
        
-for (Ship ship :
+ List%3CShip%3E
  cop
@@ -2468,48 +2468,32 @@
 hips
-) %7B%0A            ship.reset();%0A        %7D%0A
+ = new ArrayList(ships);
 %0A   
@@ -2608,52 +2608,34 @@
     
-for (Ship ship : copiedShips) %7B%0A            
+copiedShips.forEach(this::
 plac
@@ -2639,21 +2639,16 @@
 laceShip
-(ship
 );%0A     
@@ -2654,98 +2654,43 @@
     
-%7D%0A        for (Position position : copiedShots) %7B%0A            shootAt(position);%0A        %7D
+copiedShots.forEach(this::shootAt);
 %0A   

Use forEach syntax instead of for loop