
Java, Java, Java, Object-Oriented Problem Solving / Edition 3
by Ralph Morelli, Ralph Walde, Ralph WaldeISBN-10: 0131474340
ISBN-13: 9780131474345
Pub. Date: 12/23/2005
Publisher: Prentice Hall
Functional and flexible, this guide takes an objects-first approach to Java programming and problem using games and puzzles. Updated to cover Java version 1.5 features, such as generic types, enumerated types, and the Scanner class. Offers independent introductions to both a command-line interface and a graphical user interface (GUI). Features coverage of Unified
Overview
Functional and flexible, this guide takes an objects-first approach to Java programming and problem using games and puzzles. Updated to cover Java version 1.5 features, such as generic types, enumerated types, and the Scanner class. Offers independent introductions to both a command-line interface and a graphical user interface (GUI). Features coverage of Unified Modeling Language (UML), the industry-standard, object-oriented design tool. Illustrates key aspects of Java with a collection of game and puzzle examples. Instructor and Student resources available online. For introductory computer programming students or professionals interested in learning Java.
Product Details
- ISBN-13:
- 9780131474345
- Publisher:
- Prentice Hall
- Publication date:
- 12/23/2005
- Edition description:
- REV
- Pages:
- 880
- Product dimensions:
- 7.50(w) x 9.11(h) x 1.58(d)
Table of Contents
Preface | xiii | |
0 | Computers, Objects, and Java | 1 |
0.1 | Welcome | 2 |
0.2 | What Is a Computer? | 2 |
0.3 | Networks, the Internet, and the World Wide Web | 3 |
0.4 | Why Study Programming? | 6 |
0.5 | Programming Languages | 6 |
0.6 | Why Java? | 8 |
0.7 | What Is Object-Oriented Programming? | 10 |
Chapter Summary | 18 | |
Exercises | 20 | |
1 | Java Program Design and Development | 23 |
1.1 | Introduction | 24 |
1.2 | Designing Good Programs | 24 |
1.3 | Designing a Riddle Program | 26 |
1.4 | Java Language Elements | 33 |
1.5 | Editing, Compiling, and Running a Java Program | 48 |
1.6 | From the Java Library: System and PrintStream | 52 |
Chapter Summary | 54 | |
Solutions to Self-Study Exercises | 56 | |
Exercises | 57 | |
2 | Objects: Using, Creating, and Defining | 63 |
2.1 | Introduction | 64 |
2.2 | Using String Objects | 64 |
2.3 | Drawing Shapes with a Graphics Object (Optional) | 68 |
2.4 | Class Definition | 73 |
2.5 | CASE STUDY: Simulating a Two-Person Game | 78 |
2.6 | From the Java Library: java.util.Scanner | 91 |
Chapter Summary | 95 | |
Solutions to Self-Study Exercises | 96 | |
Exercises | 97 | |
3 | Methods: Communicating with Objects | 103 |
3.1 | Introduction | 104 |
3.2 | Passing Information to an Object | 104 |
3.3 | Constructor Methods | 111 |
3.4 | Retrieving Information from an Object | 115 |
3.5 | Passing a Value and Passing a Reference | 118 |
3.6 | Flow of Control: Control Structures | 121 |
3.7 | Testing an Improved OneRowNim | 129 |
3.8 | From the Java Library: java.lang.Object | 133 |
3.9 | Object-Oriented Design: Inheritance and Polymorphism | 135 |
3.10 | Drawing Lines and Defining Graphical Methods (Optional) | 136 |
Chapter Summary | 139 | |
Solutions to Self-Study Exercises | 140 | |
Exercises | 142 | |
4 | Input/Output: Designing the User Interface | 149 |
4.1 | Introduction | 150 |
4.2 | The Use Interface | 150 |
4.3 | A Command-Line Interface | 151 |
4.4 | A Graphical User Interface (GUI) | 159 |
4.5 | CASE STUDY: The One-Row Nim Game | 175 |
4.6 | From the Java Library: java.io.File and File Input (Optional) | 183 |
Chapter Summary | 186 | |
Solutions to Self-Study Exercises | 188 | |
Exercises | 190 | |
5 | Java Data and Operators | 195 |
5.1 | Introduction | 196 |
5.2 | Boolean Data and Operators | 197 |
5.3 | Numeric Data and Operators | 204 |
5.4 | From the Java Library: java.lang.Math | 215 |
5.5 | Numeric Processing Examples | 216 |
5.6 | From the Java Library: java.text.NumberFormat | 228 |
5.7 | Character Data and Operators | 230 |
5.8 | Example: Character Conversions | 233 |
5.9 | Problem Solving = Representation + Action | 236 |
Chapter Summary | 236 | |
Solutions to Self-Study Exercises | 238 | |
Exercises | 242 | |
6 | Control Structures | 249 |
6.1 | Introduction | 250 |
6.2 | Flow of Control: Repetition Structures | 250 |
6.3 | Counting Loops | 251 |
6.4 | Example: Car Loan | 260 |
6.5 | Graphics Example: Drawing a Checkerboard | 262 |
6.6 | Conditional Loops | 266 |
6.7 | Example: Computing Averages | 272 |
6.8 | Example: Data Validation | 275 |
6.9 | Principles of Loop Design | 277 |
6.10 | The switch Multiway Selection Structure | 278 |
6.11 | Object-Oriented Design: Structured Programming | 282 |
Chapter Summary | 290 | |
Solutions to Self-Study Exercises | 291 | |
Exercises | 298 | |
7 | Strings and String Processing | 305 |
7.1 | Introduction | 306 |
7.2 | String Basics | 306 |
7.3 | Finding Things within a String | 313 |
7.4 | Example: Keyword Search | 315 |
7.5 | From the Java Library: java.lang.StringBuffer | 317 |
7.6 | Retrieving Parts of Strings | 320 |
7.7 | Example: Processing Names and Passwords | 322 |
7.8 | Processing Each Character in a String | 323 |
7.9 | Comparing Strings | 326 |
7.10 | From the Java Library: java.util.StringTokenizer | 332 |
7.11 | Handling Text in a Graphics Context (Optional) | 334 |
Chapter Summary | 340 | |
Solutions to Self-Study Exercises | 341 | |
Exercises | 344 | |
8 | Inheritance and Polymorphism | 349 |
8.1 | Introduction | 350 |
8.2 | Java's Inheritance Mechanism | 350 |
8.3 | Abstract Classes, Interfaces, and Polymorphism | 359 |
8.4 | Example: A Toggle Button | 365 |
8.5 | Example: The Cipher Class Hierarchy | 368 |
8.6 | CASE STUDY: A Two-Player Game Hierarchy | 375 |
8.7 | Principles of Object-Oriented Design | 396 |
Chapter Summary | 397 | |
Solutions to Self-Study Exercises | 398 | |
Exercises | 400 | |
9 | Arrays and Array Processing | 405 |
9.1 | Introduction | 406 |
9.2 | One-Dimensional Arrays | 406 |
9.3 | Simple Array Examples | 413 |
9.4 | Example: Counting Frequencies of Letters | 416 |
9.5 | Array Algorithms: Sorting | 420 |
9.6 | Array Algorithms: Searching | 426 |
9.7 | Two-Dimensional Arrays | 430 |
9.8 | Multidimensional Arrays (Optional) | 437 |
9.9 | Object-Oriented Design: Polymorphic Sorting (Optional) | 439 |
9.10 | From the Java Library: java. lang. Vector | 443 |
9.11 | CASE STUDY: An N-Player Computer Game | 444 |
9.12 | A GUI-Based Game (Optional Graphics) | 452 |
Chapter Summary | 459 | |
Solutions to Self-Study Exercises | 460 | |
Exercises | 465 | |
10 | Exceptions: When Things Go Wrong | 471 |
10.1 | Introduction | 472 |
10.2 | Handling Exceptional Conditions | 472 |
10.3 | Java's Exception Hierarchy | 474 |
10.4 | Handling Exceptions within a Program | 478 |
10.5 | Error Handling and Robust Program Design | 488 |
10.6 | Creating and Throwing Your Own Exceptions | 497 |
10.7 | From the Java Library: javax.swing.JOptionPane | 501 |
Chapter Summary | 503 | |
Solutions to Self-Study Exercises | 505 | |
Exercises | 507 | |
11 | Files and Streams: Input/Output Techniques | 511 |
11.1 | Introduction | 512 |
11.2 | Streams and Files | 512 |
11.3 | CASE STUDY: Reading and Writing Text Files | 518 |
11.4 | The File Class | 530 |
11.5 | Example: Reading and Writing Binary Files | 533 |
11.6 | Object Serialization: Reading and Writing Objects | 542 |
11.7 | From the Java Library: javax.swing.JFileChooser | 547 |
11.8 | Using File Data in Programs | 548 |
Chapter Summary | 551 | |
Solutions to Self-Study Exercises | 552 | |
Exercises | 553 | |
12 | Recursive Problem Solving | 557 |
12.1 | Introduction | 558 |
12.2 | Recursive Definition | 561 |
12.3 | Recursive String Methods | 564 |
12.4 | Recursive Array Processing | 574 |
12.5 | Example: Drawing (Recursive) Fractals | 580 |
12.6 | Object-Oriented Design: Tail Recursion | 584 |
12.7 | Object-Oriented Design: Recursion or Iteration? | 586 |
12.8 | From the Java Library: javax.swing.JComboBox | 588 |
Chapter Summary | 594 | |
Solutions to Self-Study Exercises | 595 | |
Exercises | 599 | |
13 | Graphical User Interfaces | 603 |
13.1 | Introduction | 604 |
13.2 | Java GUIs: From AWT to Swing | 604 |
13.3 | The Swing Component Set | 607 |
13.4 | Object-Oriented Design: Model-View-Controller Architecture | 607 |
13.5 | The Java Event Model | 609 |
13.6 | CASE STUDY: Designing a Basic GUI | 614 |
13.7 | Containers and Layout Managers | 627 |
13.8 | Checkboxes, Radio Buttons, and Borders | 633 |
13.9 | Menus and Scroll Panes | 641 |
Chapter Summary | 650 | |
Solutions to Self-Study Exercises | 651 | |
Exercises | 653 | |
14 | Threads and Concurrent Programming | 657 |
14.1 | Introduction | 658 |
14.2 | What Is a Thread? | 658 |
14.3 | From the Java Library: java.lang.Thread | 662 |
14.4 | Thread States and Life Cycle | 668 |
14.5 | Using Threads to Improve Interface Responsiveness | 670 |
14.6 | CASE STUDY: Cooperating Threads | 678 |
14.7 | CASE STUDY: The Game of Pong | 693 |
Chapter Summary | 700 | |
Solutions to Self-Study Exercises | 702 | |
Exercises | 704 | |
15 | Sockets and Networking | 707 |
15.1 | Introduction | 708 |
15.2 | An Overview of Networks | 708 |
15.3 | Using Network Resources from an Applet | 714 |
15.4 | From the Java Library: java.net.URL | 715 |
15.5 | The Slide-Show Applet | 717 |
15.6 | Using Network Resources from an Application | 722 |
15.7 | Client/Server Communication via Sockets | 732 |
15.8 | CASE STUDY: Generic Client/Server Classes | 736 |
15.9 | Playing One-Row Nim Over the Network | 745 |
15.10 | Java Network Security Restrictions | 752 |
15.11 | Java Servlets and Java Server Pages | 753 |
Chapter Summary | 762 | |
Solutions to Self-Study Exercises | 763 | |
Exercises | 765 | |
16 | Data Structures: Lists, Stacks, and Queues | 767 |
16.1 | Introduction | 768 |
16.2 | The Linked List Data Structure | 768 |
16.3 | Object-Oriented Design: The List Abstract Data Type (ADT) | 780 |
16.4 | The Stack ADT | 785 |
16.5 | The Queue ADT | 788 |
16.6 | From the Java Library: The Java Collections Framework and Generic Types | 791 |
16.7 | Using the Set and Map Interfaces | 795 |
16.8 | The Binary Search Tree Data Structure | 799 |
Chapter Summary | 801 | |
Solutions to Self-Study Exercises | 803 | |
Exercises | 806 | |
A | Coding Conventions | 811 |
B | The Java Development Kit | 819 |
C | The ASCII and Unicode Character Sets | 828 |
D | Java Keywords | 829 |
E | Operator Precedence Hierarchy | 830 |
F | Java Inner Classes | 832 |
G | Java Autoboxing and Enumeration | 837 |
H | Java and UML Resources | 841 |
Index | 843 |
Customer Reviews
Average Review:
Most Helpful Customer Reviews
![]() |
This is a review of the 3RD EDITION, published December 2005. The book starts from scratch. You do not have to know anything about Java. What Morelli and Walde offer is an education that emphasises an object oriented programming mentality, from the very start. The text shows how Java enforces a strict OO coding. Unlike C++, for example, which was bolted onto C as a superset, and accordingly has to accept (endure would be a better word) procedural C code as valid. So thoroughly do the authors want you to learn OO programming that there is no mention of the alternative of procedural programming in other languages! They don't want to confuse the reader, who is probably assumed to be new to programming in general, and not just Java. Now the book also holds true to its claim in the title of 'Problem Solving'. It causes the book to be relatively weak in explaining how to write a user interface with Java widgets. Yes, there is a couple of chapters on this. But the topic is deprecated. The book's clear strength is in the majority of its space being devoted to tackling various problems. Chosen so that you don't need a fancy UI over them. The problems can be handled as pure computations, with perhaps a minimal I/O and stdout user interface. Of course, the problems were also chosen so that the authors could demonstrate solutions that take advantage of OO design. An important extra benefit is that you get acquainted with the various Java collection classes. These come with the standard Java distribution. They implement key ideas in computer science, like lists, queues, stacks, arrays and hash tables. Professional Java programmers use these extensively. They have a lot of functionality, that is stable and well-tested by Sun itself. These classes address both the OO and problem solving themes of the book. Being Java classes, they are inherently objects to be used in an OO manner. But the sheer utility of these for handling many problems is also a good education for you.
|