So I have got to this stage on my Battleships game where i have created an array and filled a 10x10 grid I now want to make it so that the user can input co-ordinates x,y,z and the grid update to S instead of O, what is the best way of going around this im very new to java.
GRID
public class Grid1 {
public void BattleshipsGrid() {
System.out.println ("Players Board");
char [][] grid = new char [10][10];
//FILL GRID//
for(int outerLoopValue = 0; outerLoopValue<10;outerLoopValue++)
{
for(int innerLoopValue = 0; innerLoopValue<10;innerLoopValue++)
{
grid[outerLoopValue][innerLoopValue]='O';
}
}
//END OF FILL GRID//
//DRAW GRID//
for(int outerLoopValue = 0; outerLoopValue<10;outerLoopValue++)
{
System.out.println("");
for(int innerLoopValue = 0; innerLoopValue<10;innerLoopValue++)
{
System.out.print(grid[outerLoopValue][innerLoopValue]+" ");
}
}
}
}
MAIN GAME
public class Game {
public static void main (String args[]) {
//Calling Player grid
Grid1 CPUGrid = new Grid1();
Grid1 PGrid = new Grid1();
System.out.println("Welcome to Battleships");
System.out.println("Please choose the co-ordinates for your ships");
System.out.println("");
System.out.println("");
CPUGrid.BattleshipsGrid();
}
}