02115 Java Programming | ||
Autumn 2011 |
A short summary of the development of the three TechSupport variants all having the same class structure:
Responder
class - Code 5.3 - has been extended and supplied with
an ArrayList<String> holding responses
initialized
by the class constructor. A reply (a respons) is then picked
from the responses
list by use of a randomly
generated integer index
value.
getInput()
method of class InputReader
has been changed from returning the input line just as one
String
into a method returning the words
of the input line as a HashSet<String>
-
Code 5.5
The response is then generated by first using the words
from the input line as keys used to get the reply
from a previously generated
HashMap<String, String> responseMap
- Code 5.4 - holding replies corresponding to keywords
as "slow"
, "bug"
, ...
The reply corresponding to the first key matching a word
from the input line is returned:
return response;
- Code
5.7
and the while
loop is interrupted
If no matching key was available from the responseMap
then a default reply is chosen randomly using the same
procedure as in the tech-support2 project
return pickDefaultResponse();
- Code 5.7
Section 6.11 (page 199) is about Debuggers. If you have not previously worked through section 3.13 (page 79) then do it as part of the preparations for this week.
Chapter 7 is about designing classes: What makes a class design either
good or bad ?
As a minimal preparation to this week study the Chapters 6 and 7 of
BK to the following extent:
At the end of this week you are supposed to be familiar with the following parts of the BK textbook:
If you have not previously learned about testing, then
the chapter must be studied carefully. Look at it as useful
information to be used when you later are going to test your
Mandatory Assignment program classes.
Do Exercises 6.16 - 6.18 when you take a closer look
at section 6.4 (pages 177-186)
In sections 6.5 - 6.10 (pages 186-199)
the authors address testing based on the merits of
Mr. Hacker T. Largebrain offering to us
a simple calculator. Both the code and the testing looks
convincing but doing the three Exercises 6.21 - 6.23
reveal that something must be wrong.
Work with sections 6.11 - 6.12 and do the Exercises
6.34, 6.35 and 6.36
Feel free to do other exercises along with your study of the zuul game, e.g. Exercises 7.23-7.26 and 7.37-7.39
enum
type and reveals a strong resemblance
to classes - section 9.1 on page 20Math.
prefix
by applying a special form of the import
clause
as shown in Example 165 (page 141). At first
read only the first seven lines (the last line to be read is
out.println(...);
)
Newest edition: 5. September
Previous editions:
- 8. April (just the heading and footing)