Programming and Problem Solving with Java

(やまだぃちぅ) #1

  • Chapter 1 Introduction to Object-Oriented Programming Preface xv

    • 1.1 Overview of Object-Oriented Programming

      • What Is Programming?

      • How Do We Write a Program?

      • Computer Can Use? 1.2 How Is Java Code Converted into a Form That a



    • 1.3 How Does Interpreting Code Differ from Executing It?

      • Execution? 1.4 How Is Compilation Related to Interpretation and

      • Programming Language? 1.5 What Kinds of Instructions Can Be Written in a

      • Object-Oriented Programming Languages



    • 1.6 What’s Inside the Computer?

    • 1.7 Problem-Solving Techniques

      • Ask Questions

      • Look for Things That Are Familiar

      • Solve by Analogy

      • Means-Ends Analysis

      • Divide and Conquer

      • The Building-Block Approach

      • Merging Solutions

      • Mental Blocks: The Fear of Starting

      • Object-Oriented Problem Solving

      • Case Study: Party Planning

      • Summary

      • Quick Check

      • Exam Preparation Exercises

      • Programming Warm-Up Exercises

      • Programming Problems

      • Case Study Follow-Up





  • Chapter 2 Java Syntax and Semantics, Classes, and Objects

    • 2.1 The Elements of Java Programs

      • Syntax and Semantics

      • Syntax Templates

      • Naming Program Elements: Identifiers

      • Built-in Types in Java

      • Classes and Objects

      • Defining Terms: Declarations

      • Field Declarations vi | Contents

      • Assignment and Expressions

      • Beyond Minimalism: Adding Comments to Code

      • Output

      • Input

      • Interactive Input and Output



    • 2.2 Application Construction

      • Blocks



    • 2.3 Application Entry, Correction, and Execution

      • Entering Application Code

      • Compiling and Running an Application

      • Finishing Up



    • 2.4 Classes and Methods

      • User Classes

      • Methods

      • Case Study: Display a Name in Multiple Formats



    • 2.5 Testing and Debugging

      • Summary

      • Quick Check

      • Exam Preparation Exercises

      • Programming Warm-Up Exercises

      • Programming Problems

      • Case Study Follow-Up





  • Chapter 3 Arithmetic Expressions

    • 3.1 Overview of Java Data Types

    • 3.2 Numeric Data Types

      • Integral Types

      • Floating-Point Types



    • 3.3 Declarations for Numeric Types

      • Named Constant Declarations

      • Variable Declarations



    • 3.4 Simple Arithmetic Expressions

      • Arithmetic Operators

      • Increment and Decrement Operators



    • 3.5 Compound Arithmetic Expressions

      • Precedence Rules

      • Type Conversion and Type Casting



    • 3.6 Additional Mathematical Methods

    • 3.7 Value-Returning Class Methods

    • 3.8 Additional String Operations

      • The length Method Contents | vii

      • The indexOf Method

      • The substring Method

      • Converting Strings to Numeric Values

      • Noninteractive Input/Output



    • 3.9 Applications with Multiple Class Files

      • Case Study: Small Company Payroll



    • 3.10 Testing and Debugging

      • Summary

      • Quick Check

      • Exam Preparation Exercises

      • Programming Warm-Up Exercises

      • Programming Problems

      • Case Study Follow-Up





  • Chapter 4 Selection and Encapsulation

    • 4.1 Flow of Control

      • Selection



    • 4.2 Conditions and Logical Expressions

      • The boolean Data Type

      • Logical Expressions

      • Precedence of Operators

      • Relational Operators with Floating-Point Types



    • 4.3 The if Statement

      • The if-else Form

      • Blocks (Compound Statements)

      • The if Form



    • 4.4 Nested if Statements

      • The Dangling else



    • 4.5 Encapsulation

    • 4.6 Abstraction

      • Data and Control Abstraction

      • Case Study: Warning Notices



    • 4.7 Testing and Debugging

      • Testing Strategies

      • The Test Plan

        • Execution Tests Performed Automatically During Compilation and



      • Summary

      • Quick Check

      • Exam Preparation Exercises

      • Programming Warm-Up Exercises

      • Programming Problems viii | Contents

      • Case Study Follow-Up





  • Chapter 5 File Objects and Looping Statements

    • 5.1 File Input and Output

      • Files

      • Using Files

      • An Example Application Using Files



    • 5.2 Looping

      • The while Statement

      • Phases of Loop Execution

      • Loops Using the while Statement

      • Count-Controlled Loops

      • Event-Controlled Loops

      • Looping Subtasks

      • How to Design Loops

      • Designing the Flow of Control

      • Designing the Process Within the Loop

      • The Loop Exit

      • Nested Loops

      • General Pattern

      • Designing Nested Loops



    • 5.3 Mutable and Immutable Objects

      • A Parameter-Passing Analogy

      • Case Study: Average Income By Gender



    • 5.4 Testing and Debugging

      • Loop-Testing Strategy

      • Test Plans Involving Loops

      • Summary

      • Quick Check

      • Exam Preparation Exercises

      • Programming Warm-Up Exercises

      • Programming Problems

      • Case Study Follow-Up





  • Chapter 6 Object-Oriented Software Design and Implementation

    • 6.1 Software Design Strategies

    • 6.2 Objects and Classes Revisited

    • 6.3 Object-Oriented Design

      • Object-Oriented Problem Solving

      • Software Engineering



    • 6.4 The CRC Card Design Process

      • Identifying the Initial Classes Through Brainstorming

      • Filtering Contents | ix

      • Determining Responsibilities

      • Inheritance



    • 6.5 Functional Decomposition

      • Writing Modules



    • 6.6 Object-Oriented Implementation

      • Class Interface Design

      • Internal Data Representation

      • Responsibilities as Methods



    • 6.7 Packages

      • Package Syntax

      • Packages with Multiple Compilation Units

      • Package Example

      • Computing Profession 6.8 Ethics and Responsibilities in the

      • Software Piracy

      • Privacy of Data

      • Use of Computer Resources

      • Case Study: Address Book



    • 6.9 Testing and Debugging

      • Summary

      • Quick Check

      • Exam Preparation Exercises

      • Programming Warm-Up Exercises

      • Programming Problems

      • Case Study Follow-Up





  • Chapter 7 Inheritance, Polymorphism, and Scope

    • 7.1 Inheritance

      • An Analogy



    • 7.2 Inheritance and the Object-Oriented Design Process

    • 7.3 How to Read a Class Hierarchy

      • Overriding

      • Hiding

      • Polymorphism



    • 7.4 Derived Class Syntax

    • 7.5 Scope of Access

      • Internal Scope

      • External Scope



    • 7.6 Implementing a Derived Class

      • Constructors in Derived Classes

      • Overloading and Method Signatures x | Contents

      • Accessing Overridden and Hidden Methods and Fields

      • A Concrete Example



    • 7.7 Copy Constructors

    • 7.8 Output and Input of Objects

      • Case Study: Extending the Address Book



    • 7.9 Testing and Debugging

      • Summary

      • Quick Check

      • Exam Preparation Exercises

      • Programming Warm-Up Exercises

      • Programming Problem

      • Case Study Follow-Up





  • Chapter 8 Event-Driven Input and Output

    • 8.1 Frames

      • Import Classes and Declare Fields

        • Some of Their Properties Instantiate Frame Objects and Specify



      • Add Output to the Content Pane

      • Make the Frame Visible on the Screen



    • 8.2 Formatting Output

      • Using GridLayoutfor Tabular Output

      • Alignment of Text Within Jlabels



    • 8.3 Event Handling

      • Creating a Button

      • Creating and Registering a Button Event Listener

      • An Event-Handling Example

      • Event Loops



    • 8.4 Entering Data Using Fields in a Frame

    • 8.5 Creating a Data Entry Field

    • 8.6 Using a Field

    • 8.7 Reading Data in an Event Handler

      • Case Study: Totaling Rainfall Amounts



    • 8.8 Handling Multiple Button Events

      • Case Study: A Simple Calculator



    • 8.9 Testing and Debugging

      • Summary

      • Quick Check

      • Exam Preparation Exercises

      • Programming Warm-Up Exercises Contents | xi

      • Programming Problems

      • Case Study Follow-Up





  • Chapter 9 Exceptions and Additional Control Structures

    • 9.1 Exception-Handling Mechanism

      • The try-catch-finally Statement

      • Generating an Exception with throw

      • Exception Classes



    • 9.2 Additional Control Statements

      • The switch Statement

      • The do Statement

      • The for Statement

      • Guidelines for Choosing a Looping Statement



    • 9.3 Additional Java Operators

      • Assignment Operators and Assignment Expressions

      • Increment and Decrement Operators

      • Bitwise Operators

      • The ?: Operator

      • Operator Precedence

      • Case Study: Monthly Rainfall Averages



    • 9.4 Testing and Debugging

      • Summary

      • Quick Check

      • Exam Preparation Exercises

      • Programming Warm-Up Exercises

      • Programming Problems

      • Case Study Follow-Up





  • Chapter 10 One-Dimensional Arrays

    • 10.1 Atomic Data Types

    • 10.2 Composite Data Types

    • 10.3 One-Dimensional Arrays

      • Declaring an Array

      • Creating an Array

      • Declaring and Creating an Array with an Initializer List

      • Accessing Individual Components

      • Out-of-Bounds Array Indexes

      • Aggregate Array Operations



    • 10.4 Examples of Declaring and Processing Arrays

      • Occupancy Rates xii | Contents

      • Sales Figures

      • Character Counts



    • 10.5 Arrays of Objects

      • Arrays of Strings

      • Arrays of User-Defined Objects



    • 10.6 Arrays and Methods

    • 10.7 Special Kinds of Array Processing

      • Partial (or Sub) Array Processing

      • Indexes with Semantic Content

      • Case Study: Grading True/False Tests



    • 10.8 Testing and Debugging

      • Summary

      • Quick Check

      • Exam Preparation Exercises

      • Programming Warm-Up Exercises

      • Programming Problems

      • Case Study Follow-Up





  • Chapter 11 Array-Based Lists

    • 11.1 Lists

    • 11.2 List Class

      • Brainstorming the List Class

      • CRC Card

      • Refining the Responsibilities

      • Internal Data Representation

      • Responsibility Algorithms for Class List

      • Test Plan



    • 11.3 Sorting the List Items

      • Responsibility Algorithms for Class ListWithSort

      • Class ListWithSort



    • 11.4 Sorted List

      • Brainstorming the Sorted List

      • Responsibility Algorithms for Class SortedList

      • Test Plan



    • 11.5 The List Class Hierarchy and Abstract Classes

    • 11.6 Searching

      • Sequential Search

      • Binary Search



    • 11.7 Generic Lists

      • Comparable Interface

      • Polymorphism Contents | xiii

      • Case Study: Merging Address Books



    • 11.8 Testing and Debugging

      • Summary

      • Quick Check

      • Exam Preparation Exercises

      • Programming Warm-Up Exercises

      • Programming Problems

      • Case Study Follow-Up





  • Chapter 12 Multidimensional Arrays and Numeric Computation

    • 12.1 Two-Dimensional Arrays

      • Array Declaration and Instantiation

      • Accessing Individual Components

      • Using Initializer Lists



    • 12.2 Processing Two-Dimensional Arrays

      • Sum the Rows

      • Sum to Columns

      • Initialize the Array

      • Two-Dimensional Arrays and Methods



    • 12.3 Multidimensional Arrays

    • 12.4 Vector Class

    • 12.5 Floating-Point Numbers

      • Representation of Floating-Point Numbers

      • Arithmetic with Floating-Point Numbers

        • in the Computer Implementation of Floating-Point Numbers





    • 12.6 Decimal Format Type

      • Case Study: Matrix Manipulation



    • 12.7 Testing and Debugging

      • Summary

      • Quick Check

      • Exam Preparation Exercises

      • Programming Warm-Up Exercises

      • Programming Problems

      • Case Study Follow-Up





  • Chapter 13 Recursion

    • 13.1 What Is Recursion?

      • Power Function Definition

      • Power Function Implementation xiv | Contents



    • 13.2 More Examples with Simple Variables

      • Calculating the Factorial Function

      • Converting Decimal Integers to Binary Numbers

      • Towers of Hanoi



    • 13.3 Recursive Algorithms with Structured Variables

      • Printing the Values in an Array

      • Binary Search



    • 13.4 Recursion or Iteration?

    • 13.5 Testing and Debugging

      • Summary

      • Quick Check

      • Exam Preparation Exercises

      • Programming Warm-Up Exercises





  • Chapter 14 Applets

    • 14.1 What Is an Applet?

    • 14.2 How Do You Write an Applet?

      • Factorial

      • Calculator



    • 14.3 How Do You Run an Applet?

      • Web Browsers

      • HTML

      • Factorial

      • Calculator

      • Case Study: Searching Experiments



    • 14.4 Testing and Debugging

      • Summary

      • Quick Check

      • Exam Preparation Exercises

      • Programming Warm-Up Exercises

      • Programming Problems

      • Case Study Follow-Up

      • Appendixes

      • Glossary

      • Answers

      • Index





Free download pdf