CS241 Terminal Class
The Terminal class is to facilitate input and output from the command line
and from files.
indent()
- Prints the current indentation to the command line.
print(String)
- Print a string to the command line.
printCall(String)
- Print procedure call information to the command line with a
carriage return.
println(String)
- Print a string to the command line with a carriage return.
printReturn(String)
- Print a return value to the command line with a
carriage return.
readDouble()
- Read a double from the command line
readInt()
- Read a integer from the command line
readWord()
- Read a string (no spaces) from the command line
recognizeAsLetter(char)
- The given character will be treated as a letter
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
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
stopTranscript
- Stop the transcript file
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