src/com/hamish/battleships/Player.java
private void placeShips() {
        Scanner systemIn = new Scanner(System.in);
        int col, row;
        String direction;
        boolean shipPlacement;

        System.out.println("Please place your ships with an column and row and the a direction, either R for" +
                "right, or D for down");

        for (Ship ship : ships) {
            shipPlacement = false;
            while (!shipPlacement) {

                System.out.println("Place ship of length " + ship.getLength());

                col = -1;
                while (col < 0 || col >= 10) {
                    col = getValue("column");
                }

                row = -1;
                while (row < 0 || row >= 10) {
                    row = getValue("row");
                }

                while (true) {
                    System.out.print("\nPlease enter the direction:\t");
                    direction = systemIn.next();
                    if (direction.equalsIgnoreCase("R") || direction.equalsIgnoreCase("D"))
                        break;
                    else
                        System.out.println("Please enter a valid option of either 'R' or 'D'");
                }


                if (checkPositionValid(col, row, ship.getLength(), direction)) {
                    if (boards[0].checkPositionClear(col, row, direction, ship.getLength())) {
                        boards[0].placeShip(col, row, direction, ship.getLength());
                        ship.setCoordinates(col, row, direction);
                        boards[0].printBoard();
                        shipPlacement = true;
                    } else {
                        System.out.println("Position not clear, please choose a clear position");
                        shipPlacement = false;
                    }
                } else
                    shipPlacement = false;
            }
        }
    }
/**
     * Called to place the ships. Gets an x coordinate and y coordinate using {@link #getCoordinate()} and direction,
     * and checks to make sure that this position is on the board. It then checks for errors then uses
     * {@link com.hamish.battleships.GameBoard#checkPositionClear(int, int, String, int)} to check to see if this is
     * available. If it isn't it loops. Then uses
     * {@link com.hamish.battleships.GameBoard#placeShip(int, int, String, int)} to put the ships on the board and
     * prints the board when done using {@link GameBoard#printBoard()}
     */
Called to place the ships. Gets an x coordinate and y coordinate using  #getCoordinate() and direction,
and checks to make sure that this position is on the board. It then checks for errors then uses
com.hamish.battleships.GameBoard#checkPositionClear(int, int, String, int) to check to see if this is
available. If it isn't it loops. Then uses
com.hamish.battleships.GameBoard#placeShip(int, int, String, int) to put the ships on the board and
prints the board when done using  GameBoard#printBoard()
Called to place the ships . Gets an x coordinate and y coordinate using #getCoordinate () and direction and checks to make sure that this position is on the board . It then checks for errors then uses com . hamish . battleships . GameBoard#checkPositionClear ( int int String int ) to check to see if this is available . If it isn ' t it loops . Then uses com . hamish . battleships . GameBoard#placeShip ( int int String int ) to put the ships on the board and prints the board when done using GameBoard#printBoard ()
private void placeShips() {
        Scanner systemIn = new Scanner(System.in);
        int col, row;
        String direction;
        boolean shipPlacement;
        System.out.println("Please place your ships with an column and row and the a direction, either R for" +
                "right, or D for down");
        for (Ship ship : ships) {
            shipPlacement = false;
            while (!shipPlacement) {
                System.out.println("Place ship of length " + ship.getLength());
                col = -1;
                while (col < 0 || col >= 10) {
                    col = getValue("column");
                }
                row = -1;
                while (row < 0 || row >= 10) {
                    row = getValue("row");
                }
                while (true) {
                    System.out.print("\nPlease enter the direction:\t");
                    direction = systemIn.next();
                    if (direction.equalsIgnoreCase("R") || direction.equalsIgnoreCase("D"))
                        break;
                    else
                        System.out.println("Please enter a valid option of either 'R' or 'D'");
                }
                if (checkPositionValid(col, row, ship.getLength(), direction)) {
                    if (boards[0].checkPositionClear(col, row, direction, ship.getLength())) {
                        boards[0].placeShip(col, row, direction, ship.getLength());
                        ship.setCoordinates(col, row, direction);
                        boards[0].printBoard();
                        shipPlacement = true;
                    } else {
                        System.out.println("Position not clear, please choose a clear position");
                        shipPlacement = false;
                    }
                } else
                    shipPlacement = false;
            }
        }
    }
private void placeShips ( ) { Scanner systemIn = new Scanner ( System . in ) ; int col , row ; String direction ; boolean shipPlacement ; System . out . println ( "Please place your ships with an column and row and the a direction, either R for" + "right, or D for down" ) ; for ( Ship ship : ships ) { shipPlacement = false ; while ( ! shipPlacement ) { System . out . println ( "Place ship of length " + ship . getLength ( ) ) ; col = - 1 ; while ( col < 0 || col >= 10 ) { col = getValue ( "column" ) ; } row = - 1 ; while ( row < 0 || row >= 10 ) { row = getValue ( "row" ) ; } while ( true ) { System . out . print ( "\nPlease enter the direction:\t" ) ; direction = systemIn . next ( ) ; if ( direction . equalsIgnoreCase ( "R" ) || direction . equalsIgnoreCase ( "D" ) ) break ; else System . out . println ( "Please enter a valid option of either 'R' or 'D'" ) ; } if ( checkPositionValid ( col , row , ship . getLength ( ) , direction ) ) { if ( boards [ 0 ] . checkPositionClear ( col , row , direction , ship . getLength ( ) ) ) { boards [ 0 ] . placeShip ( col , row , direction , ship . getLength ( ) ) ; ship . setCoordinates ( col , row , direction ) ; boards [ 0 ] . printBoard ( ) ; shipPlacement = true ; } else { System . out . println ( "Position not clear, please choose a clear position" ) ; shipPlacement = false ; } } else shipPlacement = false ; } } }
Called to place the ships.
Called to place the ships .