Assignment 3: Address Book

The goal for this assignment is to create an Address book program with - at a minimum - the following features:

An address must contain at least the first name and last name of a person.
You must be able to insert an address into the address book.
You must be able to search for an address by last name in the address book, and you must be able to find at least one occurance of that address in case there are one or more in the address book.
You must be able to delete the address that a user has searched for previously, if one was found.
You must be able to display the entire address book
Your address book must be able to use all available memory to store its addresses.

Optionally, your address book could, but does not have to, support the following features

An address can contain more fields, perhaps for street, city, zip code, phone number, email address, etc.
You should be able to find all occurances of an address, if there are several (for example, find all addresses of people with last name "Wachsmuth").
You should be able to save your address book data.
You should be able to retrieve the data you have previously saved.

Since your address book must be able to use all available memory to store addresses, you can not use an array to store addresses. Instead, you must use a linked list. That, of course, means that you first have to implement a working linked list class.

In addition, I have suggested in class to create an additional class for a ListElement which will be treated as synonymous with an "Address". I have distributed a handout explaining how the various classes and functions might work together, and we have designed the basic frame work for this program during one of our labs. As a refresher, here is the handout for the connections between the various classes. It may be helpful, but you do not have to follow it if you don't find it useful.

For your "enjoyment", I have compiled my own version of a possible "Address Book" program that you can try out. Just login to your Sciris account and type the lines:

   /usr/people/wachsmut/addressbook

to run the program. It does support all optional elements mentioned above, but perhaps there are better ways to do certain things ... it's only a "demo" version ... -:)

File name: Address.cpp

#ifndef LISTELEMENT
#define LISTELEMENT

#include <iostream.h>  // because of display method
#include "Strings.cpp"

class ListElement
{
  public: Strings fName;
  public: Strings lName;

  public: ListElement(void);
  public: ListElement(Strings, Strings);
  public: void get(void);
  public: void display(void);
};

File name: Node.cpp

#endif
#ifndef LISTNODE
#define LISTNODE
#include "Address.cpp"

class Node
{
   public: ListElement data;
   public: Node *next;

   public: Node(void);
   public: Node(ListElement);
};

File name: List.cpp

#ifndef LIST
#define LIST
#include "Address.cpp"
#include "Node.cpp"

class List
{
   private: Node *head, *current;
   private: long nNodes;        // this is optional

   public: List(void);
   public: void insert(const ListElement&);
   public: ListElement retrieve(void);
   public: void remove(void);
   public: void first(void);
   public: void next(void);
   public: void destroy();
   public: int isEmpty(void);
   public: int isFull(void);
   public: int isLast(void);
   public: int isFirst(void);
   public: int sizeOf(void);    // this is optional
};

File name: AddressBook.cpp

#include <iostream.h>
#include "Address.cpp"
#include "List.cpp"

typedef ListElement Address;

List L;

void addAddress(void)
void delAddress(void)
void showAddressBook(void)
void findLastName(void)
void showMenu(void)
char getChoice(void)
int main(void)