COSC 1010 Introduction to Software Problem Solving

Fall 2010

Homework Assignment #10

"Address Book"
Due: Friday, Dec 10th, 11:59pm CST
Submit: Turn in all of your Java source files using the D2L Dropbox.
Work may be completed in teams of two. The names of both partners must appear in a comment block at the top of your files for credit to be given.

Address Book

An address book entry includes a full name, a street address, a municipality, a state, a ZIP code, a phone number, and an e-mail address. Create a class "AddressEntry" that will represent address book entries in your program.

An address book contains an arbitrary number of entries. Create a class "AddressBook" that contains methods for reading, writing, and sorting address book entries.

Address Book Functions

The main program of your Address Book should take as an optional command-line parameter the name of a text file that contains address book entries, one field per line. If invoked with this file name, your Address Book should read in the named file to populate the initial Address Book.

The main program of the Address Book should offer five functions, detailed below:

  • List. List all of the current address book entries' full names in alphabetical order. You may assume that Strings are directly comparable without manipulation -- so don't worry about locating last names within the String, just start comparing them. In the event of a tie based on the full name field, compare entries based on street address, and so forth, through the other record fields.
  • Search. Given an index into the ordered list, print the full entry for the corresponding AddressEntry.
  • Add. Add a new entry into the current address book. This function should prompt the user for all of the fields for an AddressEntry.
  • Delete. Given a full name, delete all address book entries that match the name exactly.
  • Write. Given a file name, write out the contents of the address book as a text file, and exit the Address Book application.
  • The Professor has provided a reference implementation for you to compare against. Change to directory ~brylow/cosc1010/Demos/Project10/ on Morbius, and run java AddressBook book.txt.

    [Revised 2010 Dec 02 18:23 DWB]