CS-4811
Java Program #2
Inheritance and
Polymorphism
Date Assigned: Tuesday,
October 10, 2000
The purpose of the assignment is to demonstrate the use of inheritance and polymorphism in Java. The abstraction to be implemented is a generic ‘Shapes’ class hierarchy. The base class Shape will have the following subclasses: Line, Circle, Triangle, and Rectangle. Each shape will be described by a set of points and other shape-specific properties. Each shape must implement a polymorphic ‘draw()’ method which describes, with text output to the console, how the shape would draw itself. For instance, a Circle would draw itself by sending to the console the message:
Line el: drawing a solid line from (43, 52) to (87, 91).
There are other abstractions (classes) that would be useful for this assignment (i.e. Point). Feel free to add whatever is necessary to your program to complete the assignment. Remember that each class has a toString() message which is used by the JVM whenever an object’s ‘print representation’ is needed for text display purposes.
As always, once your commented source code is completed, email to blessing@msoe.edu the source files and a report file which summarizes how you achieved the objectives of the assignment. The report can be sent in Word .doc format, .pdf format, or .txt as a last resort.