Program 4: Aggregation


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 author As New ArrayList   ' to hold
clsName
   
Private title As String
    Private pubDate As
clsDate

    Public Sub New ( )
    Public Sub New( ByVal last As String, ByVal first As String, ByVal mi As String, _
            ByVal newTitle As String, ByVal mMonth As Integer, ByVal mDay As Integer, _
            ByVal mYear As Integer )
    Public Sub setAuthor ( ByVal index As Integer, ByVal last As String, _
            ByVal first As String, ByVal mi As String )
    Public Sub setTitle ( ByVal newTitle As String )
    Public Sub setPubDate ( ByVal month As Integer, ByVal day As Integer, ByVal year As Integer )
    Public Sub setPubDate ( ByVal month As Integer, ByVal year As Integer )
    Public Sub setPubDate ( ByVal year As Integer )

    Public Function getAuthorLastFirstMi ( ) As String
    Public Function getAuthorLastFiMi ( ) As String
    Public Function getAuthorLastFiMi_FirstMiLast ( ) As String
    Public Function getAuthorLastFirstMi_FirstMiLast ( ) As String 
    Public Function getTitle  ( ) As String
    Public Function getTitleLowercase  ( ) As String
    Public Function getPubDate ( ByVal dateFormat As String ) As String
    Protected Function convertToLowerCase  ( ByVal changeText As String ) As String 
    Protected Function convertToTitleCase  ( ByVal changeText As String ) As String 

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 Composition 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.)