Parameterise Methods how?
Hi guys
can someone show me of how to Parameterise the below Methods. the two methods do similar things but with different values contained in the method body. I need to see how the method can be parameterised so i can understand it..
Thanks alot
public static void nameofplayer() throws InterruptedException {
for (enteramount = 0; enteramount < humanpl; enteramount++) {
System.out.println("Enter name for player " + (enteramount+1) + "(human): ");
try {
//results = OutputAsInt("How many human players?");
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
results = in.readLine();
if (results != null && results.length() != 0 && results.length() < 21) {
player[enteramount] = results;
} else {
if (results.length() > 20) {
System.out.println("Too long. That is an uncool name. Try taking out the vowels");
throw new ArrayIndexOutOfBoundsException();
} else
enteramount--;
}
} catch (Exception e) {
System.out.println("You did sumthin stupid. Try again.");
enteramount--;
}
};
}
public static void computerplayer() throws InterruptedException {
int count = 0;
aileveltype = new int[numberofplayers - humanpl];
for (enteramount = humanpl ; enteramount < numberofplayers ; enteramount++) {
System.out.println("Enter name for player " + (enteramount+1) + "(computer): ");
try {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
results = in.readLine();
if (results != null && results.length() != 0) {
player[enteramount] = results;
} else {
enteramount--;
}
} catch (Exception e) {
System.out.println("Try again");
enteramount--;
}
int level = 99;
count = aiselect(count, level);
}
}