// Walker M. White
// March 11, 2012

/** Static methods to demonstrate how try-catch blocks work. */
public class Parsing {
    
    /** Parse s as a signed decimal integer and displays it.
      *  Throws: NumberFormatException if s not a signed decimal integer
      */
    public static void nextInt1(String s) {
        System.out.println("Starting nextInt1");
        
        System.out.println("The next integer is "+(Integer.parseInt(s)+1));
        
        System.out.println("Ending nextInt1");
    }
    
    /** Parse s as a signed decimal integer and displays it.
      *  Displays an error message if not an integer.
      */
    public static void nextInt2(String s) {
        System.out.println("Starting nextInt2");
        
        try {
            System.out.println("The next integer is "+(Integer.parseInt(s)+1));
        } catch (NumberFormatException nfe) {  
            System.out.println("Hey! That is not a number!"); 
        }
        
        System.out.println("Ending nextInt2");
    }
}