[Java] IO class + Doagain class

Page 3 of 3 FirstFirst 123
Results 31 to 34 of 34
  1. #31
    Mako is insane. ThePhailure772 is offline
    MemberRank
    Sep 2007 Join Date
    1,115Posts

    Re: IO class + Doagain class

    Jay be trollin' Any ways, your classes are 99% useless, the 1% use is well, to assist me in crying when people don't know what they're doing.

  2. #32
    Account Upgraded | Title Enabled! Generic230 is offline
    MemberRank
    Jul 2009 Join Date
    506Posts

    Re: IO class + Doagain class

    Quote Originally Posted by Theoretical View Post
    Jay be trollin' Any ways, your classes are 99% useless, the 1% use is well, to assist me in crying when people don't know what they're doing.
    Hi Jacob! :)
    I think this thread is over anyways.

  3. #33
    Account Upgraded | Title Enabled! jakesdexless is offline
    MemberRank
    Nov 2008 Join Date
    278Posts

    Re: [Java] IO class + Doagain class

    PHP Code:
    import javax.swing.JOptionPane;

    public class 
    DoAgain {
        public static 
    boolean ask() {
            
    String again;
            do {
                
    again JOptionPane.showInputDialog("Again? y or n? ");
                
    System.out.println("Again? y or n? " again);
            } while (
    again.equals("y") && !again.equals("n"));
            return 
    again.equals("y");
        }

    PHP Code:
    import javax.swing.*;

    public class 
    IO {

        public static 
    int getInt(String message) {
            
    int num 0;
            try {
                
    num Integer.parseInt(JOptionPane.showInputDialog(message).trim());
                
    System.out.println(message ": " num);
            } catch (
    NumberFormatException e) { // test for bad input
                
    System.err.println(e.toString()); // error message
                
    System.exit(0); // stop program
            
    }
            return 
    num;

        }

        public static 
    double getDouble(String message) {
            
    double num 0;
            try {
                
    num Double.parseDouble(JOptionPane.showInputDialog(message).trim());
                
    System.out.println(message ": " num);
            } catch (
    NumberFormatException e) { // test for bad input
                
    System.err.println(e.toString()); // error message
                
    System.exit(0); // stop program
            
    }
            return 
    num;

        }

        public static 
    String getString(String message) {
            
    String s JOptionPane.showInputDialog(message);
            
    System.out.println(message ": " s);
            return 
    s;
        }

        public static 
    char getChar(String message) {
            
    String s JOptionPane.showInputDialog(message);
            if (
    s.length() == 0) {
                
    System.out.println(message ": ");
                return 
    '\0';// null char
            
    } else {
                
    System.out.println(message ": " s.charAt(0));
                return 
    s.charAt(0); // first char
            
    }
        }

        public static 
    void println(String message) {
            
    System.out.println(message);
            
    JOptionPane.showMessageDialog(nullmessage);
        }


    My 2 versions.

    Generic knows way more Java than you do, just saying.

  4. #34
    Yuki Zygon is offline
    MemberRank
    Aug 2008 Join Date
    IllinoisLocation
    1,208Posts

    Re: IO class + Doagain class

    Quote Originally Posted by MjClarke1 View Post
    Only if you public static main void(String[] args) is in the same file, if you're calling functions from a different java file you have to create the object
    You don't need to create a new object if all your doing is accessing static methods from the class.



Page 3 of 3 FirstFirst 123

Advertisement