So I am creating a penny game where the code will randomly choose 5 cells. I set it like so:
int a = gen.nextInt(5);
int b = gen.nextInt(5);
int c = gen.nextInt(5);
int d = gen.nextInt(5);
int e = gen.nextInt(5);
int f = gen.nextInt(5);
int g = gen.nextInt(5);
int h = gen.nextInt(5);
int i = gen.nextInt(5);
int j = gen.nextInt(5);
int penny1 = Parray[a][b];
int penny2 = Parray[c][d];
int penny3 = Parray[e][f];
int penny4 = Parray[g][h];
int penny5 = Parray[i][j];
The problem is that sometimes the random cells are repeated.
How can I make it so a random array cell cannot be repeated or chosen again?
bandcto repeataas long as(c, d)doesn’t repeat(a, b), etc.?penny2repeatspenny1even if it is taken from a different cell ofParray? If so, is this allowed? In other words, may the 2D array contain duplicartes?