INFS 519
Program 2
due October 31, 2013

Notice: one week extension on Program 2 (now due November 7)

The program

In this program you will replace the linked list of from Program 1 (here) with a binary search tree as the basis for your address book. You will also save your address book in a file.

Your program will appear the same as Program 1 to the user except that it will first ask the user "Do you want to open a file? (y/n)." If the user answers "y" the program will ask for a file name, open and read the input file. Each pair of lines from the input file will be made an entry in the address book: a name line and an address line. If the user answers "n" the program will not open a file. In either case the program will continue as did Program 1.

A new operation "save" will be added to the menu. When the user selects "save" the program will ask the user for the name of a file in which to write the address book, open the file and write the entire address book to the file. This operation will be very similar to the "Display all entries" operation.

Internals

Again, you will write (among other classes) a class Table which will store entries which are (key/value) pairs of Strings. This class will have the same public methods as did Program 1 with the addition of a public void save() method and it will have none of the "mark" classes.

Table will now be implemented as a binary search tree. Each node will have two String fields (for the name and address). insert, lookUp, delete, and update will use binary search tree operations (which you will write). You will use traversals to implement "display all entries" and "save" rather than moving a mark as in Program 1. For "display all entries" use an in-order traversal but for "save" use either a pre- or post-order traversal.

To turn in

As before, you will turn in a hard-copy of your source code and a sample terminal session using operations to be provided later.