Computer Science Canada

Keyboard Scanner made easy!

Author:  jeffgreco13 [ Tue Sep 16, 2008 10:55 am ]
Post subject:  Keyboard Scanner made easy!

Here's the Keyboard Scanner function made into an object. Very, very simple to use...

code:

...
variable1 = reader1.readDouble();  // Reads a double value and assigns it to variable1
variable2 = reader1.readInt();  // Reads an integer
variable3 = reader1.readBoolean();  // Reads boolean value, True or False
variable4 = reader1.readChar();  // Reads a Character value, ASCII
variable5 = reader1.readDoubleLine();  // Reads double values on one line, returns an array of values separated by whitespace
variable6 = reader1.readIntLine();  // Reads integer values on one line, returns array of values separated by whitespace
variable7 = reader1.readCharLine();  // Same with character values, ASCII
variable8 = reader1.readString();  // Reads a string
...


So many more constructors can be added to modify the input before it is returned, the possibilities are endless.

Author:  Tony [ Tue Sep 16, 2008 11:17 am ]
Post subject:  RE:Keyboard Scanner made easy!

I thought a Scanner was already an Object, no?

http://java.sun.com/javase/6/docs/api/java/util/Scanner.html

Author:  jeffgreco13 [ Tue Sep 16, 2008 5:33 pm ]
Post subject:  Re: Keyboard Scanner made easy!

ok... shortcut then.. thats what this is

Author:  Euphoracle [ Tue Sep 16, 2008 9:38 pm ]
Post subject:  RE:Keyboard Scanner made easy!

Shortcut to what? It's an alias, essentially.


: