Deliverable 6: Polymorphism


Objectives: Use ArrayLists to demonstrate the polymorphic properties of objects..  

Description: This program is intended to provide you with experience using polymorphism, ArrayLists, and simple file I/O.


Allow the user to enter a series of references.  As each clsBook, clsJournal, or clsReference is entered, add it to an ArrayList of clsReferences.  (Research ArrayList, Collection, and Array to determine why ArrayList was deemed most appropriate for this project.)

Set up a form that includes radio buttons to allow the user to select the new format desired (MLA, APA, Chicago).  The program should also require the user to indicate where to save the formatted output using a file dialog.  (There is a file dialog demo here.) 

After the format is chosen and the file opened, the ArrayList should be sorted by first author's last name, first name, and middle initial, each element in the sorted ArrayList should have the proper formatting method (formatMLA, formatAPA, formatChicago) called, and the resulting string should be written to a new rtf file.

Sorting an array or arrayList of clsReference objects will require that you modify clsReference to implement IComparable and to include the CompareTo method.

================================

Summary:

  1. Data entry
    1. enter reference details <from previous deliverable>
    2. store references in an ArrayList
  2. Format and review references
    1.  Select format
      1. loop through ArrayList, applying the selected format, and writing to a RichTextBox control.  
  3. Specify destination file (.rtf  file)
  4. Write the contents of the RichTextBox control to an rtf file.

Interface Design

In the screens below the buttons perform the following functions:

Button Purpose
Radio buttons Create new clsBook, clsChapter, or clsReference, depending on the radio button.  Enable last, first, and middle initial fields, and add author, and save authors buttons.  Remove the tabs from the tab control (with the "remove" command), add the book tab, chapter tab, or journal tab with the "add" command, depending on the radio button. Disable the tab control (until the save authors button is clicked).
Save & Review Output Displays the reference ArrayList in sorted, formatted form in a RichTextBox control, allows the user to select the rtf file in which to save the references, and then saves the contents of the RichTectBox in the file.
Submit Book Calls the routines to set the book title, publication date, publisher, city, state, and country. It then calls the routine to add the updated object to the reference ArrayList. It also resets the name counter, sets the reference pointer to null, and calls a method to clear all book fields.
Submit Chapter Calls the routines to set the chapter title, publication month, day, and year, publisher, city, state, and country where the publisher is based, book title, and beginning page and ending page. It then calls the routine to add the updated object to the reference ArrayList. It also resets the name and editor counters, sets the reference pointer to null, and calls a method to clear all chapter fields.
Submit Journal Calls the routines to set the paper title, the journal month, day, and year of publication, journal title, the beginning page and ending page, the journal volume and number. It then calls the routine to add the updated object to the reference ArrayList. It also resets the name counter, sets the reference pointer to null, and calls a method to clear all journal fields.

For details on each of the buttons, run the demo and view the tooltip for the buttons and text fields.


Click here for some sample screenshots. 


Demo


C# Specifics:


RichTextBox

The review feature requires that you use the RichTextBox control. Write your ArrayList to the RichTextBox and then write the RichTextBox to an rtf file (using the SaveFile method) that can be read into Word.

To use a RichTextBox you will need to add a method called getRefSource to your IFormatReferences interface.  It should return the book title for a book, the book title for a chapter, and the source for a journal.  It will be used to italicize the reference source for those reference formats that require it.

You can use the Font class to italicize the reference name.

Here is a demo of a RichTextBox and Font class in action.

Here is an explanation of the RichTextBox: Class Notes