Java Reference
In-Depth Information
Next, we can:
3. Implement the classes.
Implement one class at a time. As you implement a class, as much as possible,
test its methods as soon as they are written. Do not wait until the end.
Intermediate testing may give you better ideas and may cause you to change your
mind about the design. Of course, intermediate testing is best done if the classes
are implemented in a certain order —we will see this when we look at a design
in the next several sections.
Finally,
4. Put it together.
Putting it all together in one program will be most easily done if the program
parts have been incorporated one at a time into the final program as they were
developed and tested.
This is a short discussion of object-oriented design. But, it should give you
a bit of insight into the design process. We now give an example of object-ori-
ented design.
3.4.2
An example of OO design
We design and implement a program that will give a child practice in reading a
clock. The program starts by displaying a window that asks the player (a child)
for their name (see Fig. 3.9). After the player enters their name and hits the OK
button, a second window asks for the level at which they want to play —an inte-
ger in the range 1..4.
After the player types a level number and hits the OK button, a clock ap-
pears, along with text giving the player's name, level, and score thus far. Also, a
Lesson page 3-
8 provides a
better intro to
the game.
Close this topic
and watch it!
Figure 3.9:
The clock and one of the dialog windows
Search WWH ::




Custom Search