/* * A small test driver for addressbook */ #include #include #include #include "contact.h" #include "addressBook.h" using namespace std; int main(void) { Contact c; AddressBook book; int i=1; ostringstream s; //Create a contact c.setName("John Smith"); c.setPhone("865-555-1155"); c.setEmail("john.smith@maryvillecollege.edu"); c.setCity("Maryville"); c.setState("Tennessee"); c.setZip("37804"); c.setDOB("4-20-1985"); //insert as many as we can do { s << "John Smith" << i; c.setName(s.str()); s.clear(); s.seekp(0); i++; } while(book.addContact(c)); cout << "Failed to insert on item " << i << endl; //display the addressbook for(i=0; i < book.getCount(); i++) { //display the contact book.at(i).display(cout); } //test delete cout << "Testing Delete" << endl; book.deleteContact("John Smith3"); for(i=0; i < book.getCount(); i++) { //display the contact book.at(i).display(cout); } //test search cout << "John Smith3 at " << book.search("John Smith3") << endl << "John Smith2 at " << book.search("John Smith2") << endl; return 0; }