-
method question
Hi guys
im new to java and were doing examples in workshops turing old methods to OO. this is an example i was givin. I was wondering if somone can do this example and turn it into a OO method so i can see how it can be done?
public static void main(String[] args) throws InterruptedException {
int nop = -99;
int h = -97;
System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
System.out.println("Racer");
System.out.println(" - Racer");
System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
System.out.println();
while (true) {
try {
System.out.println(" How many players?");
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String s = in.readLine();
nop = Integer.parseInt(s);
if (nop != 2 && nop != 3 && nop != 4 && nop != 5)
throw new Exception();
break;
} catch (Exception e) {
System.out.println("Bad number of players ");
}
}
-
It is a very small amout of code so you won't do any valuable refactoring. By the way, Java is a OO language so you can't write programs without using object oriented approach.
-
yeahhh did some research and and there isnt much i can do to this
thanks for your help
Similar Threads
-
By JavaSado in forum Java
Replies: 5
Last Post: 08-14-2005, 09:35 AM
-
Replies: 2
Last Post: 07-19-2005, 06:09 AM
-
By Naveen K Thalanki in forum VB Classic
Replies: 1
Last Post: 08-14-2001, 10:25 AM
-
By Jordi in forum VB Classic
Replies: 1
Last Post: 09-10-2000, 10:10 AM
-
By J.B. Boza in forum VB Classic
Replies: 3
Last Post: 08-13-2000, 02:21 AM
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