Java Reference
In-Depth Information
Figure 5.1
A first
TechSupport
dialog
This is, in fact, not very interesting at all and not very convincing when trying to pretend that
we have a technical-support person sitting at the other end of the dialog. We will shortly try to
improve this. However, before we do this, we shall explore further what we have so far.
The project diagram shows us three classes: SupportSystem , InputReader , and Responder
(Figure 5.2). SupportSystem is the main class, which uses the InputReader to get some
input from the terminal and the Responder to generate a response.
Figure 5.2
TechSupport class
diagram
6XSSRUW6\VWHP
,QSXW5HDGHU
5HVSRQGHU
Examine the InputReader further by creating an object of this class and then looking at the
object's methods. You will see that it has only a single method available, called getInput ,
which returns a string. Try it out. This method lets you type a line of input in the terminal
and then returns whatever you typed as a method result. We will not examine how this works
internally at this point, but just note that the InputReader has a getInput method that
returns a string.
Do the same with the Responder class. You will find that it has a generateResponse method
that always returns the string "That sounds interesting. Tell me more..." . This ex-
plains what we saw in the dialog earlier.
Now let us look at the SupportSystem class a bit more closely.
 
Search WWH ::




Custom Search