CS 55  Java Programming

Week 8

Agenda

References

The Java Tutorial: Object-Oriented Programming Concepts
Lecture Notes - OOP Part 1 - based on Peter van der Linden's book Just Java

Examples

  1. Human.java - one class, two instances; picture: The Human Class and Objects
  2. Point.java - invoking methods on objects; picture:  The Point Class and Objects
  3. Bicycle.java - a class, a static field, two objects; picture:  A Bicycle Class

Lab08

  1. Exercise 8.2.  The program shall meet the following additional requirements:
    • classname: Complex.
    • It shall be an application; i.e., it shall have a main() method.
    • The main() method shall test the class as follows:
      • It shall create two Complex objects, z = (1, 2) and w = (3, 5).
      • It shall print z, w, z + w, and z - w.
    • If you don't understand complex numbers, you can do exercise 8.3 instead.
  2. Exercise 8.8. The program shall meet the following additional requirements:
    • class name:  Rectangle.
    • It shall be an application; i.e., it shall have a main() method.
    • The main() method shall test the class as follows:
      • It shall create two Rectangle objects, rect1 with default dimensions and  rect2 with length 3 and width 2.
      • It shall print a descriptive representation of rect1 and rect2.

Note 1: Be sure to make use of the message passing nature of OOP. Create objects that model real-world objects. Manipulate those objects in a way that simulates the way you would manipulate their real-world counterparts.

Note 2: You have two weeks to complete this assignment. (Due: 11/02/2004)

 < CS 55  > Home Email Last Modified October 19, 2004