Class ConsoleInput

java.lang.Object
  |
  +--ConsoleInput

public class ConsoleInput
extends Object

used for console (terminal) input which is exceedingly ugly unless encapsulated in a class. This is a beginning, allows reading String, int, and double values from "standard input". Currently each function reads an entire line, and parses according to the memberfunction called, e.g., readInt In this, preliminary version bad I/O is caught, but converted to a default value (e.g., 0 for int) This is a singleton class: one, per-program instance is retunred by using getInstance()

Version:
2.0, revised 10/22/2000
Author:
Owen Astrachan

Constructor Summary
ConsoleInput()
           
 
Method Summary
static double readDouble()
          reads a line from standard input, returns first double on line catches NumberFormatException, returns 0 if caught
static int readInt()
          reads a line from standard input, returns first int on line catches NumberFormatException, returns 0 if caught
static String readString()
          reads a line from standard input, returns string
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConsoleInput

public ConsoleInput()
Method Detail

readDouble

public static double readDouble()
reads a line from standard input, returns first double on line catches NumberFormatException, returns 0 if caught

Returns:
the double read from the terminal/keyboard/stdin

readInt

public static int readInt()
reads a line from standard input, returns first int on line catches NumberFormatException, returns 0 if caught

Returns:
the int read from the terminal/keyboard/stdin

readString

public static String readString()
reads a line from standard input, returns string

Returns:
the string read from the terminal/keyboard/stdin


Generated by BlueJ