-
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);
}
}
Similar Threads
-
Replies: 2
Last Post: 10-13-2005, 11:16 AM
-
By ericelysia1 in forum Java
Replies: 34
Last Post: 05-15-2005, 06:39 PM
-
Replies: 2
Last Post: 05-03-2005, 05:52 AM
-
By Larry Hayashi in forum Architecture and Design
Replies: 2
Last Post: 05-01-2003, 11:33 AM
-
By Frank Oquendo in forum .NET
Replies: 0
Last Post: 07-24-2002, 01:41 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|