/ Published in: Java
URL: http://www.cs.indiana.edu/classes/a202-sbog/ConsoleReader.java
The infamous ConsoleReader, without which I wouldn't have learned much in Java in University, as it took a while to get my head around how input/output works in an object-oriented programming context.
Thanks to Indiana U for posting since my school's (AcadiaU) has since been taken down.
Expand |
Embed | Plain Text
/** * ConsoleReader.java * Reads input from the keyboard. * This is useful for teaching students about basic input and * output without scaring them away with the gritty details. * EXAMPLE: * ConsoleReader console = new ConsoleReader(System.in); * String txt = console.readLine(); // returns a String * -or- * int num = console.readInt(); // returns an int * -or- * Double num = console.readDouble(); // returns a double */ import java.io.InputStreamReader; import java.io.InputStream; import java.io.BufferedReader; import java.io.IOException; public class ConsoleReader { private BufferedReader reader; } try { inputLine = reader.readLine(); } } return inputLine; } public int readInt() { return n; } public double readDouble() { return x; } }
You need to login to post a comment.
