|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--ConsoleInput
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()
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 |
public ConsoleInput()
Method Detail |
public static double readDouble()
public static int readInt()
public static String readString()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |