//****************************************************************************** //****************************************************************************** XBridgeAddressBookModel::AddressBookEntry XBridgeAddressBookModel::entry(const int row) { if (row < 0 || row >= m_addressBook.size()) { return AddressBookEntry(); } return m_addressBook[row]; }
int main() { /*test 1 is a test of the AddressBookManager class and the AddressBookEntry class */ printf_s("[=================StartTest1=================]\n\n"); ABman = new AddressBookManager(); entry = AddressBookEntry(); key = AddressBookEntry(); int i = 0; do { printMenu(); printf("//:> "); scanf_s("%d", &i); processInput(i); } while (i != 8); printf_s("\n[==================EndTest1==================]\n"); delete ABman; return 0; }
AddressBookEntry MakeEntry() { char entryInfo[5][SIZE]; int relation = 1; //read in all requirements for an "entry" //and echo the input after each "return" key is pressed printf_s("First Name:> "); scanf_s("%s", entryInfo[0]); printf_s("First = %s\n", entryInfo[0]); printf_s("Last Name:> "); scanf_s("%s", entryInfo[1]); printf_s("Last = %s\n", entryInfo[1]); printf_s("Middle Name:> "); scanf_s("%s", entryInfo[2]); printf_s("Middle = %s\n", entryInfo[2]); printf_s("Address(\"Address City, State, Zipecode\")\n:> "); //have alot of trouble with this, i ended up solving the line issue //by using the file method, but just using stdin stream instead of //a file stream fflush(stdin); //flush stream first fgets(entryInfo[3], SIZE, stdin); //get whole line char *newline = strchr(entryInfo[3], '\n'); //set pointer to end of line char *newline = '\0'; //replace newline with null terminator printf_s("Address = %s\n", entryInfo[3]); printf_s("Phone Number(x-xxx-xxx-xxx)\n:> "); scanf_s("%s", entryInfo[4]); printf_s("Phone Number = %s\n", entryInfo[4]); printf_s("RelationShipType (1, 2, 3, 4, 5, 6)\n (UNKOWN, BUSINESS, FAMILY, PLEASURE, INFO, WORK)\n:> "); scanf_s("%d", &relation); printf_s("Relation = %d\n\n", relation); RelationShipType type = AddressBookEntry::intToRelation(relation); AddressBookEntry entry = AddressBookEntry(entryInfo[0], entryInfo[1], entryInfo[2], entryInfo[3], entryInfo[4], type); return entry; }
AddressBookEntry MakeSearchKey() { char entryInfo[3][SIZE]; //read in all requirements for a "key" //and echo the input after each "return" key is pressed printf_s("First Name:> "); scanf_s("%s", entryInfo[0]); printf_s("First = %s\n", entryInfo[0]); printf_s("Last Name:> "); scanf_s("%s", entryInfo[1]); printf_s("Last = %s\n", entryInfo[1]); printf_s("Phone Number(x-xxx-xxx-xxx)\n:> "); scanf_s("%s", entryInfo[2]); printf_s("Phone Number = %s\n\n", entryInfo[2]); //only paramters for first and last names, and phonenumber matter here AddressBookEntry entry = AddressBookEntry(entryInfo[0], entryInfo[1], " ", " ", entryInfo[2], UNKNOWN); return entry; }