IS 313: Data Structures in Java

Autumn 2002

Individual Assignment 2

Using collection classes and iterators

Due Friday October 11 before 11:30pm

Sometimes not-for-profit institutions need to know more about their donors than simply who are the largest donors. For example, it may be useful to know where the biggest donors live or why they made donations. For this next assignment, you will work on an expanded version of the program from the last assignment. First, you will write an expanded Donations class that reads and updates the donations file. Second, you will work on a new class that reads in an expanded names file that includes the donor's city and what plays he or she attended. This information will allow your program to present donation totals by city or by play. Finally, you will write a simple interface that allows a user to interact with the program.

Part 1

Create a new class called SavedDonations that extends the Donations class. This class should provide two new methods: Because the Donations class does not keep a record of each individual donation, your extended class must store each donation (i.e. the ID and the amount) as it is read in or added to the list. This way, it can then write all donations back to the file when the write method is called. In order to store all donations, you need to override the addDonation method so that it saves all donations.

Additional requirements (really hints)

Part 2

The names file has been expanded to include the donor's city and which plays the donor attended. Here's an example of the names file using the new format:

  Jones, Sam
  2
  Chicago
  The Miser&Tartuffe
  Smith, Alfred
  3
  Oak Park
  The Miser&The Imaginary Invalid
  Miller, Andrew
  5
  Evanston
  Tartuffe

Note that the play titles are separated by the '&' character since play titles may have spaces in them.

Using the newly formatted names file, create a class called DonorCollection that reads in this file and provides the following methods for accessing useful information:

Additional requirements (really hints)

Part 3

Write a simple driver class called DonorAdmin that uses the SavedDonations class and the DonorCollection class. This class should provide simple user interaction through command-line menus that allow a user to do the following items:

Example data files

Here are example data files for donations and names. You should find that the larger cities (e.g. Chicago) generally have larger donation totals. You will also find that one of the plays has produced larger donation totals too.
Submission

Before the due date and time, you should submit the following files through the submission Web page:

If for some reason you are unable to submit the files, you may email me them as an attachment.