method question


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: method question

  1. #1
    Join Date
    Feb 2005
    Posts
    24

    Unhappy 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 ");
    }
    }

  2. #2
    Join Date
    Sep 2006
    Posts
    68
    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.

  3. #3
    Join Date
    Feb 2005
    Posts
    24
    yeahhh did some research and and there isnt much i can do to this

    thanks for your help

Similar Threads

  1. accessing last element in vector
    By JavaSado in forum Java
    Replies: 5
    Last Post: 08-14-2005, 09:35 AM
  2. Replies: 2
    Last Post: 07-19-2005, 06:09 AM
  3. updatebatch method of the recordset
    By Naveen K Thalanki in forum VB Classic
    Replies: 1
    Last Post: 08-14-2001, 10:25 AM
  4. problem with update method after addnew method
    By Jordi in forum VB Classic
    Replies: 1
    Last Post: 09-10-2000, 10:10 AM
  5. ADO Recordset "Find" method question
    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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center