Inheritance

Design your own set of classes that illustrate inheritance.

  • Create an abstract class
    • It must have one or more properties
    • It must have one or more abstract methods.
    • It must have one or more concrete methods.
    • It must have a default constructor.
    • It must have the appropriate accessor and modifier methods.
    • It must have an overridden toString method.
  • Create another class that is a child class of your abstract class.
    • It must have one or more of its own properties. DO NOT shadow (i.e. duplicate) the properties of its parent class.
    • It must have a default constructor and the appropriate accessor and modifier methods.
    • It must override and implement the abstract methods of its abstract parent class.
    • It must have at least three, non-inherited "interesting" methods one of which must be a final method.
    • It must implement the Comparable interface
    • It must have overridden toString and equals methods.
  • Create a class that is a child to the concrete class above.
    • It must override one or more of the methods in its parent class.
    • It must have a default constructor.
    • It must have one or more "other" constructors. Use this() and super() where possible.
    • It must implement the Comparable interface
    • It must have overridden toString and equals methods.
  • Write a client class named InheritanceTest.
    • In this client class, instantiate an object from each of the two concrete classes.
    • Write code that makes use of at least 4 of the methods included in the various classes.

Your program must follow the class Coding Standards.

Preconditions:

    • None

You must hand in the following on separate pages stapled in this specified order:

    1. Neatly draw a class hierarchy chart illustrating the relationships between the first three classes as well as the Comparable interface. Use the correct types of lines and arrowheads.
    2. The source code for the InheritanceTest class.
    3. The source code for the abstract class.
    4. The source code for the concrete class that is a child of the abstract class.
    5. The source code for the concrete class that is a child of the other concrete class.
    6. Runtime output that is easy for the instructor to read.