Java Reference
In-Depth Information
5.2.2
Reading the code
The complete source code of the
SupportSystem
class is shown in Code 5.1. Code 5.2 shows
the source code of class
Responder
.
Code 5.1
The
SupportSystem
source code
/**
* This class implements a technical support system. It is
* the top-level class in this project. The support system
* communicates via text input/output in the text terminal.
* This class uses an object of class InputReader to read
* input from the user and an object of class Responder to
* generate responses.
* It contains a loop that repeatedly reads input and
* generates output until the user wants to leave.
*
* @author Michael Kölling and David J. Barnes
* @version 0.1 (2011.07.31)
*/
public
class
SupportSystem
{
private
InputReader reader;
private
Responder responder;
/**
* Creates a technical support system.
*/
public
SupportSystem()
{
reader =
new
InputReader();
responder =
new
Responder();
}
/**
* Start the technical support system. This will print a
* welcome message and enter into a dialog with the user,
* until the user ends the dialog.
*/
public
void
start()
{
boolean
finished = false;
printWelcome();
while
(!finished) {
String input = reader.getInput();
if
(input.startsWith(
"bye"
)) {
finished =
true
;
}
Search WWH ::
Custom Search