AHHH so i've been writing this code with my teachers help. IT will now be able to get 1 coordinate, but i want it to get teh same number of coordinates, i set my shipsize to.. waht can i do...my teacher said I could do a loop... but.... i couldnt get it to work....( this is jsut part of the code) you dotn the otehrs...
import java.util.ArrayList;
public class GameBoard
{
private boolean[][] i = new boolean[10][10];
boolean spotIsTaken = true;
public ArrayList<String> placeShip(int shipSize)
{
System.out.println(shipSize);
String[] letters = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j"};
int row =(int)(Math.random()*10);
int column =(int)(Math.random()*10);
while(spotIsTaken)
{
if(i[row][column])
{
row =(int)(Math.random()*10);
column =(int)(Math.random()*10);
}
else
{
spotIsTaken = false;
}
}
for (int i = )
ArrayList<String> points = new ArrayList<String>();
points.add(letters[row] + (column + 1));
System.out.println(letters[row]+ (column + 1));
return points;
}
}
// Returns an ArrayList of coordinates
// where a ship of shipSize can be placed
// Example: placeShip(3)
// could return { b3, b4, b5 }