jwo.utils
Class KeyboardInput

java.lang.Object
  |
  +--jwo.utils.KeyboardInput

public class KeyboardInput
extends Object

Class to handle keyboard input. Can prompt for user input using both standard input and graphical prompt; convert input string into numbers; and pick up conversion errors.

Version:
1.8.0, 8th November, 1998
Author:
Jo Wood.

Constructor Summary
KeyboardInput()
          Creates a keyboardInput object that handles prompting and conversion of keyboard input.
 
Method Summary
 char getChar()
          Extracts the first letter of a string typed in on the keyboard.
 double getDouble()
          Extracts a double precision number from the keyboard input.
 float getFloat()
          Extracts a floating point number from the keyboard input.
 int getInt()
          Extracts an integer number from the keyboard input.
 String getString()
          Extracts a string typed in on the keyboard.
 void prompt(String promptText)
          Prompts the user to type in something from the keyboard.
 void prompt(String windowTitle, String promptText)
          Prompts the user to type in something from the keyboard.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KeyboardInput

public KeyboardInput()
Creates a keyboardInput object that handles prompting and conversion of keyboard input.

Method Detail

prompt

public void prompt(String promptText)
Prompts the user to type in something from the keyboard. Uses standard input to gether input.

Parameters:
promptText - Message to prompt input with.

prompt

public void prompt(String windowTitle,
                   String promptText)
Prompts the user to type in something from the keyboard. Creates a graphical window to gether input.

Parameters:
windowTitle - Title of input window.
promptText - Message to prompt input with.

getInt

public int getInt()
Extracts an integer number from the keyboard input.

Returns:
Integer value extracted from keyboard input.

getFloat

public float getFloat()
Extracts a floating point number from the keyboard input.

Returns:
Floating point value extracted from keyboard input.

getDouble

public double getDouble()
Extracts a double precision number from the keyboard input.

Returns:
Double precision value extracted from keyboard input.

getString

public String getString()
Extracts a string typed in on the keyboard.

Returns:
String extracted from keyboard input.

getChar

public char getChar()
Extracts the first letter of a string typed in on the keyboard.

Returns:
First character extracted from keyboard input.