I want to generate random coordinates from 0-5 (Row,Col) without any duplicates using for loops. Basically if the numbers (3,2), (3,4), (1,4), (3,4) are generated then (3,4) will not be utilized and a new random set will be looked for.
These are the methods that generate two random numbers and loads them into the array shootP[ ]
int[] shootP = new int[2];
public static int shootRowP(int[] shootP)
{
Random rn = new Random();
shootP[0] = rn.nextInt(5)+1;//loads into ROW
System.out.print("Row:"+(shootP[0]));
return shootP[0]--;
}
public static int shootColP(int[] shootP,int[][]boardP)
{
Random rn = new Random();
shootP[1] = rn.nextInt(5)+1;//loads into Col
System.out.print(" Column:"+(shootP[1])+"/n");
return shootP[1]--;
}
I then want to have another method read in the values of shootP[0] and shootP[1] and check to see if those values were already used. Any suggestions?