-
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
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks