/* |-------------------------------------------------------------------------------| | Nathan Stewart | | Coded Spring Term 2007 | | CS163 Project 3 | |-------------------------------------------------------------------------------| */ /* This is the CLIENT PROGRAM ~ not part of the ADT! (this is part of the TESTBED) */ #include #include using namespace std; #include "table.h" #include "clientProgram.h" cprogram::cprogram() { } cprogram::~cprogram() { } int cprogram::cpInsert() { table t(1009); char yesNo; do { cout << "What would you like to insert?" << endl; cin.get(cpKey, 1009, '\n'); cin.ignore(); cout << "Insert additional information" << endl; cin.get(cpData, 1009, '\n'); cin.ignore(); if(t.adtHashFunction(cpKey, cpData)) cout << "Insert successful" << endl; else cout << "There was a problem adding the data" << endl; cout << "Would you like to insert any more data? (Y or N)" << endl; cin >> yesNo; while(cin.get() != '\n'); while(yesNo != 'y' && yesNo != 'n') { cout << "Would you like to insert any more data? (Y or N)" << endl; cin >> yesNo; while(yesNo != '\n'); } }while(yesNo != 'n'); return 1; } int cprogram::cpRemove() { table t(1009); cout << "What would you like to remove?" << endl; cin.get(cpKey, 1009, '\n'); cin.ignore(); cout << "What is the secondary data?" << endl; cin.get(cpData, 1009, '\n'); cin.ignore(); if(t.adtRemove(cpKey, cpData)) { cout << "Remove success" << endl; return 1; } else { cout << "There was a problem removing the data" << endl; return 0; } } int cprogram::cpSearch() { table t(1009); char * returnedList[100]; int count = 0; const int hashsize = 1009; cout << "What would you like to search for?" << endl; cin.get(cpKey, 1009, '\n'); cin.ignore(); if(count = t.adtRetrieve(cpKey, cpData, returnedList)) { cout << "Search result found, displaying..." << endl; for(int i = 0; i < count; i++) { cout << returnedList[i] << endl; } return 1; } else { cout << "There was a problem finding the data (Possible typo?)" << endl; return 0; } }