Assignment #4:
Inheritance and Interfaces

Objectives: Gain experience using inheritance and interfaces.  

Description: This program is intended to provide you with experience designing derived classes and interfaces.

Previous programming assignments have provided a beginning for the reference formatter program, but there is much work to be done.  You recently created a clsReference program that was designed to serve as a base class for more specific derived classes.  Part I of this program requires you to practice using inheritance.

Part I Step 1  Modify clsReference so that it can serve as an abstract class.

Part I  Step 2 Create a new class called clsBook that inherits from clsReference. It should also add the class members indicated in the figure below, including the following instance variables:

and the following methods:

Part I Step 3 Create a new class called clsChapter that inherits from clsBook.  It should also add class members indicated in the figure below, including the following instance variables:

and the following methods

Part II: Provide an abstract interface called IFormatReferences that includes the following methods:

Modify clsReference to implement IFormatReferences.  Refer back to the Reference Styles help sheet for examples.  The derived classes will inherit (and therefore must provide implementations for) the interface methods.


As always, the classes, instance variables and methods listed below are not exhaustive, and should be adapted as needed as you formulate your solution.  Note that initial designs evolve as system details become more evident.  However, you should contact the professor if you discover the need for any serious deviations from this general design.

If you use a jTextPane, you can set it to html so that you can italicize text.  To set it to html use a line like 

jtpResults.setContentType( "text/html" );  //Replace jtpResults with whatever name you choose for your jTextPane.

Note: To print a quotation mark in a string, one approach is to create a constant and then concatenate it to your output string.

final String QUOTE  = "\"";
final String NEWLINE = "<br><br>";

To italicize text, use the italics html tags:  <italics>Sample Text</italics>

Here are some sample screens.  Yours do not have to be this fancy.

When Book is selected:


When Chapter is selected: