CS 55  Java Programming

Week 9

Agenda

  • Chapter 9 - Object-Oriented Programming: Inheritance
  • Chapter 10 - Object-Oriented Programming: Polymorphism

References

  1. The Java Tutorial: Object-Oriented Programming Concepts
  2. Earthweb Networking and Communications: Java: The Essence of OOP using Java, Objects, and Encapsulation
  3. Perfection and Simplicity A Conversation with Ken Arnold, Part I
  4. Lecture Notes - OOP Part 2 - based on Peter van der Linden's book Just Java

Examples

  1. Point.java
  2. Pixel.java - subclass of Point; picture: A Pixel Class
  3. Bicycle.java
  4. TouringBicycle.java - subclass of Bicycle; picture: A TouringBicycle Class
  5. Circle.java - composition with Point; picture: A Circle Has A Point
  6. Is a Manager an Employee or a Role? Role.java - superclass of Manager, Engineer, FileClerk, etc.

Lab09

In this exercise you get to design and implement a class hierarchy of your choice.

  • Design and implement a class of your choosing.  Give it an appropriate name (should be a noun).
  • Include constructors, getter (aka accessor) and setter (aka mutator) methods, a toString() method, and other methods both public and helper, as appropriate.
  • Include a main() method that exercises the class.
  • Include prompts so that someone running your program knows how to use it.
  • Now design and implement a subclass of your class. Repeat all of the above for this subclass.
  • Your score for this assignment will be based on how well you design and implement your classes. I.e., your work should exhibit thought, effort, good design, good programming style, etc.

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.

CS 55 Home Email Last Modified November 8, 2004