Programming and Problem Solving with Java

(やまだぃちぅ) #1

xvi | Preface


scribe the software development process. Classes are covered extensively in Chapter 2,
where we first encounter Java syntax. Over the course of the next several chapters, students
learn to build separately compiled classes representing realistic objects and to add to their
sophistication gradually. In Chapter 6, we present the CRC card technique for object-ori-
ented design, and in Chapter 7 we formalize the earlier coverage of classes and introduce in-
heritance.
Unlike our other Java text,Introduction to Java™and Software Design,here we save the in-
troduction of graphical user interface components for Chapter 8. These are used only spar-
ingly in the remaining chapters, so that instructors who do not wish to focus on GUI and event
programming do not have to do so. We use a modest subset of the Swing library compo-
nents that is appropriate to a course at this level. Event driven I/O is the dominant model not
only in Java, but in the modern world of programming in general. Students come to our
classes with prior familiarity of event-driven interfaces and expect to learn how to write
programs containing them. In this book, we have thus strived to strike a balance between cov-
ering the more complex style of I/O with which students are familiar, and the more traditional
console I/O that is simpler to use for early applications.
The text uses real Java I/O classes rather than ones we supply. It would have made our
job much easier to supply a streamlined set of I/O classes to simplify Java I/O. We have seen
many books that introduce either C or Pascal-like command-line I/O classes or simplified win-
dowing classes that automatically handle events. However, our view is that using such libraries
produces students who still do not know how to write real Java programs at the end of the
course, leaving them to learn the Java I/O library on their own, without help or guidance.
Instead, we have carefully chosen a subset of the console I/O and Swing packages that is within
their grasp, and that covers all of the essential concepts necessary for them to explore ad-
ditional features of the library on their own.
All of the programs have been tested with Metrowerks CodeWarrior®or the Apple OSX
version of the Sun SDK. The program code is included on the Student Resource Disk for Java,
which accompanies your new book.

Chapter Coverage
Chapter 1begins with basic definitions, computer concepts, software life cycle, compilation ver-
sus interpretation, problem solving techniques including object-oriented problem solving,
and a problem-solving case study resulting in an object-oriented algorithm. We introduce ob-
jects from the very beginning, defining them in this first chapter, and consistently using ob-
ject-oriented terminology throughout the book.
In Chapter 2, we examine the chartype, the Stringclass, and concatenation expressions.
We also examine the process of declaring a reference variable, instantiating an object, as-
signing its address to the variable, and using the object. These are difficult but essential
concepts for beginners to grasp. Chapter 2 further covers sequential control flow, simple
output to System.out, and string input via System.in. This gets students off to a quick start with
a simple working program and past the mechanics of program entry and execution.
Because the input operation is a value-returning method and the output operation is a
void method, we take the opportunity in the second major portion of Chapter 2 to explain
Free download pdf