Self-Test 7

Wed, Dec. 8 2010


Before you start:

Take a look at StringList and StringListDemo (downloadable from the Examples link), which is an example of how an array can be used as an instance variable.

Exercise (part 1):

Today we are going to modify our LexUnit class (hw 5) to store the synonyms in an array of type String, which will be expanded if necessary.

We will only change the implementation of synonyms today (changing the implementation for orthForms requires the same steps):

Write a demo program that creates a LexUnit and adds 3 synonyms.
Adding the 3rd synonym should cause your resizing code to be executed.
Make sure your demo program calls each method in the LexUnit class at least once.

Exercise (part 2):

In your demo program, create an array of LexUnits.
Repeatedly prompt the user to enter an orthForm and its synonyms, create a LexUnit with this information, and add the LexUnit to your array.
Print all LexUnits in the array.
Note that this array may also become full at some point - add code to resize it if necessary.