In the Code below i have a program using multi dimensional arrays. I have a quick question on "How to" ad a checking system so my random class does not generate the same "type" of horse twice. For instance right now i have my program pick a random color with the name stallion i do not want it to pick blue twice
Main Class
String[][] horses = {{"Black ","White ","Gray ","Old ","Young ",
"Pink ","Yellow ","Brown ","Orange ","Cyan ",
"Purple ","Tan ","Cerulean ","Silver ","Gold ",
"Red ","Green ","Blue ","Maroon ","Marigold ",
"Iron ","Paper ","Wood ","Zinc ","Metal "},
{"Stallion"}
};
String[][] horsePlace = {{pickRand.get(horses[0]), pickRand.get(horses[0]), pickRand.get(horses[0])
, pickRand.get(horses[0]), pickRand.get(horses[0]), pickRand.get(horses[0])},
{pickRand.get(horses[1]), pickRand.get(horses[1]), pickRand.get(horses[1]),
pickRand.get(horses[1]), pickRand.get(horses[1])}};
Random Class
import java.util.Random;
class pickRand {
public static String get (String[] array) {
Random generator = new Random();
int rnd = generator.nextInt(array.length);
return array[rnd];
}
}