CS241 Terminal Class

The Terminal class is to facilitate input and output from the command line and from files.

o indent()
Prints the current indentation to the command line.
o print(String)
Print a string to the command line.
o printCall(String)
Print procedure call information to the command line with a
carriage return.
o println(String)
Print a string to the command line with a carriage return.
o printReturn(String)
Print a return value to the command line with a
carriage return.
o readDouble()
Read a double from the command line
o readInt()
Read a integer from the command line
o readWord()
Read a string (no spaces) from the command line
o recognizeAsLetter(char)
The given character will be treated as a letter
o startTranscript(String)
Start a transcript file that logs all input and output
The file is saved to the same directory as the project file
Under Windows 95, use Cafe/Word/WordPad to view the text file
o startTranscript(String, boolean)
Start a transcript file that logs all input and output
The file is saved to the same directory as the project file
Under Windows 95, use Cafe/Word/WordPad to view the text file
o stopTranscript
Stop the transcript file
o readInputFromFile(String)
Reads the input from the given file instead of the command line
The file must be in the same directory as the project file

Constructor

Terminal
  public Terminal()

Methods

indent
  public static void indent()
Prints the current indentation to the command line.
Returns:
none
print
  public static void print(String s)
Print a string to the command line. No indentation is added.
Parameters:
s - string to output
Returns:
none
printCall
  public static void printCall(String s)
Print procedure call information to the command line with a
carriage return. Indentation is increased for future println
and indent calls.
Parameters:
s - procedure call information to output
Returns:
none
println
  public static void println(String s)
Print a string to the command line with a carriage return.
Indentation added if printCall and printReturn are used.
Parameters:
s - string to output
Returns:
none
printReturn
  public static void printReturn(String s)
Print a return value to the command line with a
carriage return. Indentation is decreased for future println
and indent calls.
Parameters:
s - string (the formatted return value) to output
Returns:
none
readDouble
  public static double readDouble()
Read a double from the command line
Returns:
a double
readInt
  public static int readInt()
Read a integer from the command line
Returns:
a integer
readWord
  public static String readWord()
Read a string from the command line
Returns:
a string
recognizeAsLetter
  public static void recognizeAsLetter(char c)
Adds a character to those recognized by readWord.
Parameters:
c - character to add
Returns:
none
startTranscript
  public static void startTranscript(String fn)
Start a transcript file that logs all input and output
The file is saved to the same directory as the project file
Under Windows 95, use Cafe/Word/WordPad to view the text file
Parameters:
fn - string to call transcript file
Returns:
none
startTranscript
  public static void startTranscript(String fn,
                                     boolean controller)
Start a transcript file that logs all input and output
The file is saved to the same directory as the project file
Under Windows 95, use Cafe/Word/WordPad to view the text file
Parameters:
fn - string to call transcript file
controller - true if pause/resume/stop buttons desired
Returns:
none
stopTranscript
  public static void stopTranscript()
Stop the transcript file from logging input and output
Returns:
none
readInputFromFile
  public static void readInputFromFile(String fn)
Start reading the input from the given file instead of the command line
The file must be in the same directory as the project file
Parameters:
fn - string with file name to read from
Returns:
none

Return to the CS241 Home Page