import java.util.Scanner; public class Main { public static int gridArray1[][] = null; public static int gridArray2[][] = null; public static boolean playerTurn = true; public static int count = 0; public static void setGridDimensions(int x_max, int y_max) { Main.gridArray1 = new int[x_max][y_max]; Main.gridArray2 = new int[x_max][y_max]; for (int i = 0; i < x_max; i++) { for (int j = 0; j < y_max; j++) { gridArray1[i][j] = -1; gridArray2[i][j] = -1; } } } static void placeShip(int starting_x, int starting_y, int length, int direction) { count++; int ships[] = new int[10]; int battleshipArrayPositions1[] = new int[4]; int cruiserArrayPositions1[] = new int[3]; int submarineArrayPositions1[] = new int[3]; int destroyerArrayPositions1[] = new int[2]; int carrierArrayPositions2[] = new int[5]; int battleshipArrayPositions2[] = new int[4]; int cruiserArrayPositions2[] = new int[3]; int submarineArrayPositions2[] = new int[3]; int destroyerArrayPositions2[] = new int[2]; if (playerTurn) { if (direction == 0) { for (int i = starting_x; i < starting_x + length; i++) { Main.gridArray1[i][starting_y] = 0; } } else { for (int i = starting_y; i < starting_y + length; i++) { Main.gridArray1[starting_x][i] = 0; } } } else { if (direction == 0) { for (int i = starting_x; i < starting_x + length; i++) { Main.gridArray2[i][starting_y] = 0; } } else { for (int i = starting_y; i < starting_y + length; i++) { Main.gridArray2[starting_x][i] = 0; } } } } boolean isConflictingShipPlacement(int starting_x, int starting_y, int length, int direction) { return false; } static int shoot(int x, int y) { if (playerTurn) { for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if (Main.gridArray2[i][j] == 0) { return 0; } } } } else { } return 0; } boolean hasBeenAttempted(int x, int y) { return false; } static void displayGrid(boolean showShips) { int count = 0; System.out.print(\" 0 1 2 3 4 5 6 7 8 9\"); if (showShips) { if (playerTurn) { for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if (j % 10 == 0) { System.out.print(\"\ \" + count + \" \"); count++; } if (Main.gridArray1[i][j] == -1) { System.out.print(\"- \"); } else if (Main.gridArray1[i][j] == 0) { System.out.print(\"@ \"); } else if (Main.gridArray1[i][j] == 1) { System.out.print(\"+ \"); } else { System.out.print(\"X \"); } } } } else { for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if (j % 10 == 0) { System.out.print(\"\ \" + count + \" \"); count++; } if (Main.gridArray2[i][j] == -1) { System.out.print(\"- \"); } else if (Main.gridArray2[i][j] == 0) { System.out.print(\"@ \"); } else if (Main.gridArray2[i][j] == 1) { System.out.print(\"+ \"); } else { System.out.print(\"X \"); } } } } } else { if (playerTurn) { for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if (j % 10 == 0) { System.out.print(\"\ \" + count + \" \"); count++; } if (Main.gridArray1[i][j] == -1) { System.out.print(\"- \"); } else if (Main.gridArray1[i][j] == 0) { System.out.print(\"- \"); } el.