Register your product to gain access to bonus material or receive a coupon.
Click for author interviews and demos of four SimpleGUI examples. |
This book presents a careful balance between traditional problem-solving techniques and object-oriented design. Embracing the object-oriented paradigm, the authors introduce objects early (Chapter 2) and use them throughout, introducing features as needed in a gentle manner. Chapters 4 - 7 focus on the traditional data and control structures, using objects as needed. Chapter 8 provides a more in-depth study of object-oriented design, providing detailed coverage of visibility, polymorphism, and inheritance.
Applications and AppletsFocusing on applications early, the book supports user interaction by providing a package called simpleIO. Applets are first introduced in Chapter 4 where the authors use them in an optional section on graphics to introduce the AWT and its features for drawing simple graphical patterns. They are studied extensively in Chapters 9 and 10 where the intricacies of the AWT, programming for the web, and GUI programming are covered.
Graphical User Interfaces (GUIs)Starting in Chapter 2, the authors integrate a GUI library that allows students to better understand concepts through visualization and have some fun. GUI concepts are always presented in the context of good problem solving and program development. Optional sections on graphics appear starting in Chapter 4, again to spur student interest and keep them motivated.
Proven Software Development ProcessThe book conveys the relationship between good problem-solving skills and effective software development by consistently applying a proven software development method that has been adapted to the object-oriented paradigm.
Helpful Learning FeaturesThe authors employ several features to enhance the usefulness of this book as a teaching tool. These include syntax displays, program style displays, end-of-section exercises, examples, case studies, error discussions, and chapter reviews. Also, interviews with famous computer scientists provide glimpses into various careers in computer science.
You can browse or download the simpleIO package as well as the source code for all the programs that appear in the book. The file structure is:
Because of small technical glitches in compatibility between versions of the Java Abstract Windows Toolkit we provide source files only. Code has been tested using JDK 1.1.3 on Unix, CodeWarrior on Macintosh, JBUILDER and Semantic Cafe on Windows 95.
In order to use the classes and methods in the simpleIO package you must (1) compile the package, and (2) make the folder with the compiled classes accessible to the java compiler and application runner. Unfortunately this differs on the three popular platforms (Unix, Macintosh and Windows) as well as within different Integrated Programming Environments such as CodeWarrior, Semantic, Borland. These notes are intended to give you tips, rather than guide you through the process.
We use the JDK on Unix as an example. Other environments should include extensive print and on-line resources to help you adapt these instructions to your environment. This is the simplest way to set up the package. You, or your systems administrator may find more sophisticated ways to configure the structure.
1. We recommend that you keep the organization of the psjava folder we provide. Because simpleIO is a package, the compiler and runner will look for files such as simpleIO/SimpleGUI.class rather than SimpleGUI.class. If you keep the psjava structure you can reference "simpleIO/SimpleGUI.class" as shown in step 3.
2. To compile the package, make the psjava folder (directory) your working directory. In Unix, the command:
psjava% javac simpleIO/*.java
will compile the package, placing the .class files in the simpleIO folder. Note that psjava% is the Unix prompt.
3. You should create projects in separate folders. The sourceCode structure demonstrates how classes that work together are clustered in folders. For example, the folder psjava/sourceCode/Chapter02 contains two .java files. In order to reference the simpleIO support files you must set the CLASSPATH variable to the folder that contains them.
The quick and dirty (but space expensive) way to include the simpleIO package in a project folder is to create a sub-folder (subdirectory) called simpleIO. Copy the .class files that you created in step two from the psjava/simpleIO folder to this directory.
The more responsible solution is to set the CLASSPATH variable to search for the folder that contains the simpleIO package. A package corresponds to a folder (directory.) Thus the psjava folder contains the package simpleIO because the folder contains the simpleIO folder. The rule in Java is that the compiler and applications runner search for classes in the system structure by default. That is why they can always find classes from standard packages. If the CLASSPATH variable is not set, then the default path is the current working directory and any of its subdirectories. If the CLASSPATH variable is set, then you must explicitly include the current working directory in the search path so that your own project files will be found. In UNIX you set the class path as follows:
psjava%setenv CLASSPATH {the entire path}/psjava/:.
Note the ":" and "." at the end. This says the directory {....}/psjava/ will be in the path AND (:) so will the current directory (.). You must substitute your complete path to /psjava in the statement above. For example Ursula has a copy of the structure under her root:
psjava%setenv CLASSPATH ~wolz/psjava/:.
Although we have tested, and retested the simpleIO package and the source code extensively, things slip through the cracks.
Please send mail to wolz@tcnj.edu if you run into problems or simply need clarification on something.
Erratta and update information can be found at: http://www.tcnj.edu/~wolz/psjava/update.html.
During Fall 1998, we will attempt to update the psjava (source code and simpleIO folders) as needed. The versionDate.html file provides the date of the most recent version.
Click below for Supplements related to this title:
Supplements
I. PROBLEM SOLVING AND PROGRAMMING WITH OBJECTS.
1. Introduction to Computers and Programming.
Overview of Computers.
Computer Components.
Computer Networks.
Overview of Programming Languages, Then and Now.
Processing a High-Level Language Program.
Problem Solving and Programming Using Classes.
Creating a Program in an Integrated Programming Environment.
Chapter Review.
2. Problem Solving and Java.
The Software Development Method.
Applying the Software Development Method.
Case Study: Converting Units of Measurement.
Overview of a Java Program.
Reserved Words and Identifiers.
Data Types.
Class Definitions.
Method Definitions.
Chapter Review.
3. Methods, Statements, and Expressions.
Method Bodies: Where the Action Takes Place.
Calling Methods.
Assignment Statements.
Operations and Expressions.
Processing Integers.
Case Study: Evaluating Coins.
Processing Strings.
Case Study: Pig Latin.
Writing Code with Style.
Common Errors and Debugging.
Chapter Review.
4. Program Design with Methods and Graphics.
Building Programs from Existing Information.
Case Study: Finding the Area and Circumference of a Circle.
Extending a Problem Solution.
Case Study: Finding the Most Pizza for Your Money.
Extending a Problem Solution through Inheritance.
Reuse of Methods in Class Math.
Accessors, Modifiers, Constructors, and Class Methods.
Introduction to Computer Graphics.
Common Programming Errors.
Chapter Review.
II. TRADITIONAL CONTROL AND DATA STRUCTURES.
5. Selection Structures.
Control Structures.
Boolean Expressions.
The if Statement.
if Statements with Compound Statements.
Decision Steps in Algorithms.
Case Study: Payroll Problem.
Case Study: Computing Insurance Dividends.
Hand Tracing an Algorithm.
Nested if Statements and Multiple-Alternative Decisions.
The switch Statement and Simple GUI Menus.
Exceptions and try-catch Blocks.
Common Programming Errors.
Chapter Review.
6. Repetition Structures.
Repetition in Programs: The while Statement.
Accumulating a Sum.
Case Study: Computing Company Payroll.
State-Controlled loops.
Case Study: A Checking Account Program.
Loop Design and do-while Loop.
The for Statement.
Case Study: Displaying a Temperature Table.
Loops in Graphics Programs (Optional).
Introduction to Recursive Methods.
Debugging and Testing Programs with Loops.
Common Programming Errors.
Chapter Review.
7. Arrays and Vectors.
Array Declarations and Indices.
Processing Arrays and Array Elements.
Case Study: Computing Statistics.
Operations on Whole Arrays.
Searching and Sorting an Array.
Analysis of Algorithms: Big-O Notation (Optional).
Arrays of Objects.
Case Study: Payroll Problem with an Employee Array.
Vectors.
More Input/Output: Using Files and display Row (Optional).
Multi-dimensional Arrays: Arrays of Arrays.
Common Programming Errors.
Chapter Review.
III. DESIGN FOR GUI AND NETWORK PROGRAMMING.
8. Object-Oriented Design.
Java Classes Revisited.
Case Study: A General Purpose Rectangle Class.
Modular Programming and Reuse.
Encapsulation, Inheritance, Visibility, and Packages.
Polymorphism.
Another Look at Inheritance.
Case Study: Is a Square a Rectangle?
Class Members and Instance Members: Static and Final.
Abstract Classes.
Case Study: Areas of Different Geometric Figures.
Multiple Inheritance and Interfaces.
Common Programming Errors.
Chapter Review.
9. Applets, Graphical-User Interfaces, and Threads.
Web Programming and Client, Server Model.
Applets, Panels, Containers, Components.
The Basic Interactive Applet.
Case Study: Click me.
Case Study: User-controlled Animation.
Introduction to Threads.
Case Study: Threaded Animation.
Browser, Applet Interaction.
Chapter Review.
10. GUIs as a Vehicle for Object-Oriented Design.
Abstraction Layers for User Input/Output.
Output to the User: Label, Canvas, Fonts, and Layout Managers.
Discrete User Input: Buttons, Boxes and Lists.
Continuous and Textual Input.
Low-Level User Input.
Turn Taking within the Event Model.
Case Study: TicTacToe.
Applications and Applets: Menus.
Chapter Review.
IV. MORE ADVANCED TRADITIONAL CONTROL AND DATA STRUCTURES.
11. Recursion.
Recursive Methods.
Argument and Local Variable Stacks.
Recursive Mathematical Functions.
Recursive Methods with Arrays and Vectors.
Case Study: Summing the Values in an Array.
Binary Search.
Case Study: Recursive Binary Search.
Problem Solving with Recursion.
Case Study: Towers of Hanoi Problem.
Common Programming Errors.
Chapter Review.
12. Linked Data Structures.
Linked Lists.
Stacks.
Queues.
Binary Trees.
Implementing a Binary Search Tree.
Efficiency of a Binary Search Tree.
Common Programming Errors.
Chapter Review.
Appendices.
Summary of the Essentials of the Language.
Pointers to On-line resources (Libraries, Learn HTML).
The Component Class and its Companions (for GUIs).
The IO package.
The Vector Class.
The String Class.
Primitive Types.
Object Wrappers for Primitive Types.
Unicode.
The Thread Class and the Runnable Interface. 0201357437T04062001
p. iii, Second paragraph ends with a footnote reference. The footnote is missing. p. ix add dedication to Elliot and Ursula's families p. 44 transpose yards and meters in third comment line in PieceOfFabric. p. 44 change displayString to displayResult at end of Fig. 2.2. p. 53 First line under Primitive Type double - change integral to integer p. 57, transpose yards and meters in third comment line in PieceOfFabric. p. 57 change displayString to displayResult at end of Fig. 2.5. p. 72 transpose yards and meters in third comment line in PieceOfFabric. p. 72 change displayString to displayResult at end of Fig. 3.1. p. 85 add "the type on the left" to end of margin note p. 95 exercise 2, place semicolon after each statement (a. - q.). Replace n. (a repeat of f.) with x = -y * a / b; p. 100 in readCoins, delete private twice. p. 105 delete import simpleIO.*; p. 137 round(x) Returns the integer value closest to x. Put double and long on first line and float and int on second line. (Type double argument gives type long result; type float argument gives type int result.) p. 147 delete import java.io.*; p. 159 change line above Drawing Filled Figures to int y2 = 20; p. 162 Change Fig. 4.37 caption to Class Pirate p. 164 Exercise 4, call to method fillArc needs another argument, add , 150 to argument list. p. 220 Exercise 3. Delete word a before dice. p. 222 in line above syntax display, delete , boolean values p. 223 change Note 4: The selector type can be any ordinal type except boolean. p. 229 The space before darn should be in left brace. The bracket at the end of the line should be a close parenthesis. p. 244 Change "oversees" to "overseas" in the biography column p. 256 Change last word of first paragraph under Testing from myCompany to mine. p. 260 In exercise 1, change computePayTotals to displayPayTotals. p. 267 Add { to end of first line. p. 277, 279, 281 change running head to 6.5 The for Statement p. 288 Delete period in "import.java.awt.*;" in 6th line of code p. 357 In method writeArrayToFile, in the for loop heading, change <= to <. p. 358 Add line: employees = new Employee[arraySize]; after first line. Add line: employees[count] = new Employee(); as first line of while loop. p. 362 In Example 7.1, draw arrow from matrix[1][2] to box with value 0.0. p. 386 Add sentence "The statement below uses this constructor." to paragraph above line that begins // Creates a new object Sigma . In line below this one, delete word int two times. p. 388 change third line in Fig. 8.2 continued to: return 2 * (length + width); p. 399 Change "part of" to "importing" in fifth line of code p. 422 In first method rand, in line beginning with return, change max to (max - min + 1). p. 424, in self-check exercise 2 change max to (max - min + 1). p. 435 In example 8.10, second line, change (just the border color) to (the interior color). p. 438 Change extends Triangle to extends DrawableTri two times. p. 461 In line that begins // Create each component Sigma change name panel to selections panel. p. 484 Change // Yield is static Sigma to // yield is static Sigma p. 498 Insert ap. Before getParameter. p. 512 Transpose TextArea and TextField in left hand column p. 516 In first constructor, insert after pen = p; the line: xSpace = x; ySpace = y; p. 555 First paragraph, change last sentence to: Appendix D summarizes MouseEvent methods to figure out which Sigma p. 556 Delete sentence in parentheses at end of first paragraph. p. 566 Delete line int r, c; in method gameOver. p. 570 Programming exercise 1, change reference to Self-Check Exercise 2. p. 618 In Fig. 11.26 User history, change B to C and C to B. p. 636, Fig. 12.9 draw a black diagonal line in the link field of the last list node (box under the word "box"). p. 638, first line, change showListTraversal to showList to match text at end of p. 636. p. 709 Word "Double" should appear in blue p. 711 Word "Integer" should appear in blue p. 715 Header "The Object Class" should appear in smaller font p. 793 Section 3.4, exercise 1. part d. change to -4/16 = 0 16/-4 = -4 p. 794 exercise 7. Parts d and e, delete quotes around T. p. 800 Section 6.1, exercise 1, 4 output lines should be 9, 81, 6561 1/18/99