package taxi;
import java.io.*;

/**
 *Class handles all input from STDIN
 *
 *@author Doug Halperin
 *@version 1.0
 */
public class KBInputDevice implements InputDevice 
{
	/**
	 *The actual io device used
	 */
	private BufferedReader device;

	/**
	 *Initializes the device, readying it for use
	 */
	public KBInputDevice() {
		device = new BufferedReader(new InputStreamReader(System.in));
	}

	/**
	 *Reads a character stream from the InputDevice
	 *
	 *@return the string read or null if there was an error
	 */
	public String readString() {
		String s = null;

		try {
			s = device.readLine();
		} catch (IOException ioe) {
			/* just return null on error */
		}

		return s;
	}
	
	/**
	 *Reads a number from the KBInputDevice
	 *return the number read or 0 if there was an error
	 *@return int
	 */
	public int readNumber() {
		int num = 0;
		
		String s= readString();
		if (s == null) 
			return num;
	
		try {
			num = Integer.parseInt(s);
		} catch (NumberFormatException nfe) {
		}

		return num;
	}
	
	public void abort() {
	}
	
}

