#include #include "phone_book.h" using namespace std; int main ( ) { // Every test prints out the number of phone numbers in the book; PhoneBook phoneBook; cout << "Test 1: Operations on an empty book" << endl; cout << "Total size of book = " << phoneBook.numNumbers ( ) << endl; cout << "Size of area code ( 909 ) = " << phoneBook.numAreaCodeNumbers ( 909 ) << endl; cout << "Number of phone numbers with area code ( 909 ) and prefix 234 = " << phoneBook.numAreaCodeAndPrefixNumbers ( 909, 234 ) << endl; cout << "--------------------------------------------------------" << endl; cout << "Test 2: Inserting first phone number" << endl; phoneBook.insertPhoneNumber ( 909, 345, 1111 ); phoneBook.print ( ); cout << "Total size of book = " << phoneBook.numNumbers ( ) << endl; cout << "--------------------------------------------------------" << endl; cout << "Test 3: Inserting 3 additional phone numbers to the same area code" << endl; phoneBook.insertPhoneNumber ( 909, 345, 2222 ); phoneBook.insertPhoneNumber ( 909, 345, 3333 ); phoneBook.insertPhoneNumber ( 909, 123, 1111 ); phoneBook.print ( ); cout << "Total size of book = " << phoneBook.numNumbers ( ) << endl; cout << "Size of area code ( 909 ) = " << phoneBook.numAreaCodeNumbers ( 909 ) << endl; cout << "Number of phone numbers with area code ( 909 ) and prefix 345 = " << phoneBook.numAreaCodeAndPrefixNumbers ( 909, 345 ) << endl; cout << "--------------------------------------------------------" << endl; cout << "Test 4: Inserting duplicate number at tail of phone number list" << endl; phoneBook.insertPhoneNumber ( 909, 345, 1111 ); phoneBook.print ( ); cout << "Total size of book = " << phoneBook.numNumbers ( ) << endl; cout << "--------------------------------------------------------" << endl; cout << "Test 5: Inserting duplicate number in middle of phone number list" << endl; phoneBook.insertPhoneNumber ( 909, 345, 2222 ); phoneBook.print ( ); cout << "Total size of book = " << phoneBook.numNumbers ( ) << endl; cout << "--------------------------------------------------------" << endl; cout << "Test 6: Inserting duplicate number at head of phone number list" << endl; phoneBook.insertPhoneNumber ( 909, 123, 1111 ); phoneBook.print ( ); cout << "Total size of book = " << phoneBook.numNumbers ( ) << endl; cout << "--------------------------------------------------------" << endl; cout << "Test 7: Inserting 4 more numbers to the same area code" << endl; phoneBook.insertPhoneNumber ( 909, 123, 2222 ); phoneBook.insertPhoneNumber ( 909, 123, 3333 ); phoneBook.insertPhoneNumber ( 909, 123, 4444 ); phoneBook.insertPhoneNumber ( 909, 123, 5555 ); phoneBook.print ( ); cout << "Total size of book = " << phoneBook.numNumbers ( ) << endl; cout << "--------------------------------------------------------" << endl; cout << "Test 8: Searching for a phone number that does exist" << endl; cout << "Searching for 909-345-1111...." << flush; if ( phoneBook.search ( 909, 345, 1111 ) ) { cout << "found" << endl; } else { cout << "not found" << endl; } cout << "Total size of book = " << phoneBook.numNumbers ( ) << endl; cout << "--------------------------------------------------------" << endl; cout << "Test 9: Searching for a phone number that does not exist" << endl; cout << "Searching for 909-345-9876...." << flush; if ( phoneBook.search ( 909, 345, 9876 ) ) { cout << "found" << endl; } else { cout << "not found" << endl; } cout << "Total size of book = " << phoneBook.numNumbers ( ) << endl; cout << "--------------------------------------------------------" << endl; return 1; }