In the first part of this chapter we discussed more aspects of problem solving. We reviewed the top-down approach to solving problems and showed how to use the documentation created by following the software development method as the outline of the final program. We also showed how we could extend a solution to one problem to form the basis of the solution for another problem. We discussed how structure charts are used to show relationships between different levels of subproblems or between algorithm steps and their refinements.
We discussed the importance of control structures to structured programming and introduced the three kinds of control structures: sequence, selection, and repetition.
Several guidelines for using program comments were discussed. Well-placed and carefully worded comments and a structure chart are two essential parts of the documentation necessary for a program. In the remainder of the chapter, we discussed the representation of the various steps in an algorithm and illustrated the stepwise refinement of algorithms.
In this chapter enumeration types were introduced, along with Ada's standard input/output library for reading and displaying enumeration values. Enumeration types are useful in allowing the programmer to give meaningful names to values such as days of the week, months of the year, colors of the rainbow, and command sets.
This chapter also continued the use of packages, begun in Chapter 2 with the
use of the input/output libraries. We discussed Ada's standard package
Calendar
and a package called Screen
that is provided
with this book. Finally, we introduced the spider package, also provided with
this book, which we will use throughout the book to illustrate a number of
concepts.
TYPE CompassPoints IS (North, South, East, West);defines a type whose values are enumerated as a list of identifiers
HELP
in the center of the screen three times at 1-second
intervals. (Hint: To "flash" a word, display a word, then display the same
number of spaces in the same spot on the screen.)
Copyright © 1996 by Addison-Wesley Publishing Company, Inc.