For each of the inputs (name, phoneno), I am using Random Number Generator to assign the inputs to a method. My goal is to get all possible combinations of methods to an input.
Below are my codes. What if I have 1000 of inputs and methods? Is there any efficient way to this this?
public static void main(String[] args) {
for (int i = 0; i < 9; i++) {
Random myRand = new Random();
int randomInteger = myRand.nextInt(10);
if (randomInteger == 0) {
name = methodA();
phoneno = methodA();
} else if (randomInteger == 1) {
name = methodA();
phoneno = methodB();
} else if (randomInteger == 2) {
name = methodB();
phoneno = methodB();
} else if (randomInteger == 3) {
name = methodB();
phoneno = methodA();
} else if (randomInteger == 4) {
name = methodC();
phoneno = methodC();
} else if (randomInteger == 5) {
name = methodC();
phoneno = methodA();
} else if (randomInteger == 6) {
name = methodC();
phoneno = methodB();
} else if (randomInteger == 7) {
name = methodA();
phoneno = methodC();
} else if (randomInteger == 8) {
name = methodB();
phoneno = methodC();
}
}
}
public static String methodA() {
//do something
}
public static String methodB() {
//do something
}
public static String methodC() {
//do something
}
Any help will be appreciated. Thank You
See Question&Answers more detail:os