3. Object-Oriented Programming
This section under construction.
Overview.
In object-oriented programming, we write Java code to create new data types, specifying the values and operations to manipulate those values. The idea originates from modeling (in software) real-world entities such as electrons, people, buildings, or solar systems and extends readily to modeling abstract entities such as bits, numbers, programs or operating systems.- 3.1 Data Types describes how to use existing reference data types, for text processing image processing.
- 3.2 Creating Data Types describes how to create user-defined data types using Java's class mechanism.
- 3.3 Designing Data Types considers important techniques for designing data types, emphasizing APIs, encapsulation, immutability, and design-by-contract.
- 3.4 Case Study: N-Body Simulation presents a case study that simulates the motion of N particles, subject to Newton's laws of gravity.
Java programs in this chapter.
Below is a list of Java programs in this chapter. Click on the program name to access the Java code; click on the reference number for a brief description; read the textbook for a full discussion.
REF PROGRAM DESCRIPTION 3.1.1 ChargeClient.java Charged particles 3.1.2 AlbersSquares.java Albers squares 3.1.3 Luminance.java Luminance library 3.1.4 Grayscale.java Converting color to grayscale 3.1.5 Scale.java Image scaling 3.1.6 Fade.java Fade effect 3.1.7 Potential.java Visualizing electric potential 3.1.8 GeneFind.java Finding genes in a genome 3.1.9 Cat.java Concatenating files 3.1.10 StockQuote.java Screen scraping for stock quotes 3.1.11 Split.java Splitting a file 3.2.1 Charge.java Charged-particle implementation 3.2.2 Stopwatch.java Stopwatch 3.2.3 Histogram.java Histogram 3.2.4 Turtle.java Turtle graphics 3.2.5 Spiral.java Spira mirabilis 3.2.6 Complex.java Complex numbers 3.2.7 Mandelbrot.java Mandelbrot set 3.2.8 StockAccount.java Stock account 3.3.1 Complex.java Complex numbers (revisited) 3.3.2 Counter.java Counter 3.3.3 Vector.java Spatial vectors 3.3.4 Document.java Document 3.3.5 CompareAll.java Similarity detection 3.4.1 Body.java Gravitational body 3.4.2 Universe.java N-body simulation
Exercises.
Include a link.Old stuff.
- 3.5 Inheritance introduces a technique to define the relationships among objects known as inheritance. We cover interfaces and subtyping.
- 3.6 Purple America presents a case study to visualization geographical and election data for US presidential elections.
