Well, you are right at your guess. SavitchIn is a simle console input class. I was using it and when I go back and checked the code for it I saw the method that I was using includes some "string" stuff in it. And this is sort of controversial to what I am trying to do isn' t it. Instead of using Java's handy String class I am trying to make a true string class. Well, at least at a basic level... I am really cofused now... I think I am going back to this data structures book that I have.. I might get some inspirations
By the way, I checked the Savitch code and yes, it actually have some method that reads more than one char at a time
But is it any help, I don't know..
{
/**
Reads a line of text and returns that line as a String
value. The end of a line must be indicated either by a
new-line character '\n' or by a carriage return '\r'
followed by a new-line character '\n'. (Almost all systems
do this automatically. So you need not worry about this
detail.) Neither the '\n', nor the '\r' if present, are
part of the string returned. This will read the rest of a
line if the line is already partially read.
*/
public static String readLine( )
{
char nextChar;
String result = "";
boolean done = false;
while (!done)
{
nextChar = readChar( );
if (nextChar == '\n')
done = true;
else if (nextChar == '\r')
{
//Do nothing.
//Next loop iteration will detect '\n'.
}
else
result = result + nextChar;
}
return result;
}