Program 4: Aggregation


FUTURE: Get rid of Save Authors button!

FUTURE: Require RichTextBox in P4.

Objectives: Gain experience designing classes using aggregation.  

Description: This program is intended to provide you with additional experience with classes and object instantiation, as well as utilizing aggregation to take advantage of code reuse.


Develop a new class called clsReference that has the following members:

public class clsReference
{
   
private ArrayList nameArrayList = new ArrayList();   // to hold clsName
   
private string title;
    private clsDate pubDate;


    public clsReference ( )
    public clsReference (string last, string first, string mi, string newTitle, int mMonth, int mDay, int mYear)
    public void setAuthor (int index, string last, string first, string mi)
    public void setTitle (string newTitle)
    public void setPubDate (int month, int day, int year)
    public void setPubDate (int month, int year)
    public void setPubDate (int year)

   public string getAuthorLastFirstMi ( )
    public string getAuthorLastFiMi ( )
    public string getAuthorLastFiMi_FirstMiLast ( )
    public string getAuthorLastFirstMi_FirstMiLast ( )  
    public string getTitle ( )
    public string getTitleLowercase ( )
    public string getPubDate (string dateFormat)
    protected string convertToLowerCase (string changeText)
    protected string convertToTitleCase (string changeText)  

End Class

...

The accessor and mutator methods for author must be capable of handling multiple names, i.e., an ArrayList of names.  Refer back to the Reference Styles help sheet for examples.  Make sure you define the methods in the order listed above.


Refer to the Association notes for assistance.


 


The Add Authors button should call the setAuthor method of the clsReference object, and clear the textboxs.  Display a message box or status line confirming what you have done.

The Save All Authors button should place the focus in the title textbox.  Display a message box or status line confirming what you have done.

The Save Reference button should call the setTitle method of the clsReference object, the setPubDate method of the clsReference object, and then build the output string for the preview output box.  Display a message box or status line confirming what you have done.  (The demo shows only the year of the publication date, and also shows four different versions of the author using getAuthorLastFirstMi, getAuthorLastFiMi, getAuthorLastFiMi_FirstMiLast, and getAuthorLastFirstMi_FirstMiLast. Nothing is italicized since it is difficult or impossible to display portions of a textbox in italics.)