diff options
| author | Connor McDowell <[email protected]> | 2024-03-04 18:57:19 -0800 |
|---|---|---|
| committer | Connor McDowell <[email protected]> | 2024-03-04 18:57:19 -0800 |
| commit | 39e329258f39ca30c4a8acc3595be7fa7396360b (patch) | |
| tree | 399352796e46cac06eb9d23364c6f98a79e4a5f1 | |
| parent | exception fixed (diff) | |
| download | homework-7-connormcdowell275-39e329258f39ca30c4a8acc3595be7fa7396360b.tar.xz homework-7-connormcdowell275-39e329258f39ca30c4a8acc3595be7fa7396360b.zip | |
testing still
| -rw-r--r-- | Project1/contacts.cpp | 186 | ||||
| -rw-r--r-- | Project1/program.cpp | 88 |
2 files changed, 139 insertions, 135 deletions
diff --git a/Project1/contacts.cpp b/Project1/contacts.cpp index e380479..8db0c50 100644 --- a/Project1/contacts.cpp +++ b/Project1/contacts.cpp @@ -193,98 +193,99 @@ void addContact(contact newContact, size_t MAX, contact_list contacts[]) void contact_list::AddContact(contact& Contact) { - contacts_[size_++] = Contact; //CURRENTLY TESTING - //for (size_t i = 0; i < size_, i++;) - //{ - // size_t a = contacts_[i].Get_a(); - // for (a = 1; ++i;) - // { - // contacts_[i].Set_a(0); - // size_t temp = contacts_[i].Get_id(); - // for (auto j = temp; j < size_; j++) - // { - // if (contacts_[i].Get_id() != 0) - // { - // i = i + 1; - // } - // } - // char firstName[30]; - // char lastName[30]; - // char Email[105]; - // char StreetAddress[45]; - // char City[35]; - // char State[4]; - // int Zip = 0; - // contacts_[i].Set_id(i); - // //contacts_[i].Set_a(t); - // cin.ignore(1000, '\n'); - // cout << "Please enter each piece of information when you are prompted to" << endl; - // cout << "enter first name: " << endl; - // cin >> firstName; - // contacts_[i].Set_firstName(firstName); - // cout << "enter last name: " << endl; - // cin >> lastName; - // contacts_[i].Set_lastName(lastName); - // cout << "enter Email: " << endl; - // cin >> Email; - // contacts_[i].Set_email(Email); - // cout << "enter Street Address: " << endl; - // cin >> StreetAddress; - // contacts_[i].Set_streetAddress(StreetAddress); - // cout << "enter city: " << endl; - // cin >> City; - // contacts_[i].Set_city(City); - // cout << "enter State as two letter abbreviation: " << endl; - // cin >> State; - // contacts_[i].Set_state(State); - // cout << "Please enter the next value as a series of numbers" << endl; - // cout << "enter Zip: " << endl; - // cin >> Zip; - // contacts_[i].Set_zip(Zip); - // break; - // } - //} - //for (size_t i = 0; i < size_; i++) - //{ - // char firstName[30]; - // char lastName[30]; - // char Email[105]; - // char StreetAddress[45]; - // char City[35]; - // char State[4]; - // int Zip = 0; - // contacts_[i].Set_a(0); - // contacts_[i].Set_id(i + 1); - // //newContact[i].count = t; - // cin.ignore(1000, '\n'); - // cout << "Please enter each piece of information when you are prompted to" << endl; - // cout << "enter first name: " << endl; - // cin >> firstName; - // contacts_[i].Set_firstName(firstName); - // cout << "enter last name: " << endl; - // cin >> lastName; - // contacts_[i].Set_lastName(lastName); - // cout << "enter Email: " << endl; - // cin >> Email; - // contacts_[i].Set_email(Email); - // cout << "enter Street Address: " << endl; - // cin >> StreetAddress; - // contacts_[i].Set_streetAddress(StreetAddress); - // cout << "enter city: " << endl; - // cin >> City; - // contacts_[i].Set_city(City); - // cout << "enter State as two letter abbreviation: " << endl; - // cin >> State; - // contacts_[i].Set_state(State); - // cout << "Please enter the next value as a series of numbers" << endl; - // cout << "enter Zip: " << endl; - // cin >> Zip; - // contacts_[i].Set_zip(Zip); - // size_t id = i + 1; - // contacts_[i].Set_id(id); - // break; - //} + for (size_t i = 0; i < size_, i++;) + { + size_t a = contacts_[i].Get_a(); + for (a = 1; ++i;) + { + contacts_[i].Set_a(0); + size_t temp = contacts_[i].Get_id(); + for (auto j = temp; j < size_; j++) + { + if (contacts_[i].Get_id() != 0) + { + i = i + 1; + } + } + char firstName[30]; + char lastName[30]; + char Email[105]; + char StreetAddress[45]; + char City[35]; + char State[4]; + int Zip = 0; + contacts_[i].Set_id(i); + //contacts_[i].Set_a(t); + cin.ignore(1000, '\n'); + cout << "Please enter each piece of information when you are prompted to" << endl; + cout << "enter first name: " << endl; + cin >> firstName; + contacts_[i].Set_firstName(firstName); + cout << "enter last name: " << endl; + cin >> lastName; + contacts_[i].Set_lastName(lastName); + cout << "enter Email: " << endl; + cin >> Email; + contacts_[i].Set_email(Email); + cout << "enter Street Address: " << endl; + cin >> StreetAddress; + contacts_[i].Set_streetAddress(StreetAddress); + cout << "enter city: " << endl; + cin >> City; + contacts_[i].Set_city(City); + cout << "enter State as two letter abbreviation: " << endl; + cin >> State; + contacts_[i].Set_state(State); + cout << "Please enter the next value as a series of numbers" << endl; + cout << "enter Zip: " << endl; + cin >> Zip; + contacts_[i].Set_zip(Zip); + //contacts_[size_++] = Contact; + break; + } + } + for (size_t i = 0; i < size_; i++) + { + char firstName[30]; + char lastName[30]; + char Email[105]; + char StreetAddress[45]; + char City[35]; + char State[4]; + int Zip = 0; + contacts_[i].Set_a(0); + contacts_[i].Set_id(i + 1); + //newContact[i].count = t; + cin.ignore(1000, '\n'); + cout << "Please enter each piece of information when you are prompted to" << endl; + cout << "enter first name: " << endl; + cin >> firstName; + contacts_[i].Set_firstName(firstName); + cout << "enter last name: " << endl; + cin >> lastName; + contacts_[i].Set_lastName(lastName); + cout << "enter Email: " << endl; + cin >> Email; + contacts_[i].Set_email(Email); + cout << "enter Street Address: " << endl; + cin >> StreetAddress; + contacts_[i].Set_streetAddress(StreetAddress); + cout << "enter city: " << endl; + cin >> City; + contacts_[i].Set_city(City); + cout << "enter State as two letter abbreviation: " << endl; + cin >> State; + contacts_[i].Set_state(State); + cout << "Please enter the next value as a series of numbers" << endl; + cout << "enter Zip: " << endl; + cin >> Zip; + contacts_[i].Set_zip(Zip); + size_t id = i + 1; + contacts_[i].Set_id(id); + //contacts_[size_++] = Contact; + break; + } //cout << newContact[i]->Name << "\n" << newContact[i]->Email << "\n" << newContact[i]->StreetAddress << "\n" << newContact[i]->City << "\n" << newContact[i]->State << "\n" << newContact[i]->Zip << endl; @@ -340,7 +341,8 @@ void contact_list::AddContact(contact& Contact) void contact_list::Print() const { //prints all info but count and bool for every existing (non trash value filled) contact struct - //CURRENTLY WORKING + //CURRENTLY not working + for (auto i = 0u; i < size_; ++i) { diff --git a/Project1/program.cpp b/Project1/program.cpp index 50b0723..cc67419 100644 --- a/Project1/program.cpp +++ b/Project1/program.cpp @@ -23,6 +23,8 @@ int main() size_t t = 0; contacts.set_size(MAX); + + cout << contacts.get_size() << endl; while (O == 1) { //cout << MAX << endl; @@ -39,50 +41,50 @@ int main() { case 1: //addNew(newContact, MAX, t); - //contacts.AddContact(newContact); + contacts.AddContact(newContact); //addContact(newContact, contacts.get_size(), contacts[MAX]); - for (auto i = 0u; i < MAX; ++i) - { - char firstName[30] = {}; - char lastName[30] = {}; - char Email[105] = {}; - char StreetAddress[45] = {}; - char City[35] = {}; - char State[4] = {}; - int Zip = 0; - newContact.Set_a(0); - //newContact.Set_id(i + 1); - //newContact[i].count = t; - cin.ignore(1000, '\n'); - cout << "Please enter each piece of information when you are prompted to" << endl; - cout << "enter first name: " << endl; - cin >> firstName; - newContact.Set_firstName(firstName); - cout << "enter last name: " << endl; - cin >> lastName; - newContact.Set_lastName(lastName); - cout << "enter Email: " << endl; - cin >> Email; - newContact.Set_email(Email); - cout << "enter Street Address: " << endl; - cin >> StreetAddress; - newContact.Set_streetAddress(StreetAddress); - cout << "enter city: " << endl; - cin >> City; - newContact.Set_city(City); - cout << "enter State as two letter abbreviation: " << endl; - cin >> State; - newContact.Set_state(State); - cout << "Please enter the next value as a series of numbers" << endl; - cout << "enter Zip: " << endl; - cin >> Zip; - newContact.Set_zip(Zip); - size_t id = i + 1; - newContact.Set_id(id); - newContact.print(); - contacts.AddContact(newContact); - break; - } + //for (auto i = 0u; i < MAX; ++i) + //{ + // char firstName[30] = {}; + // char lastName[30] = {}; + // char Email[105] = {}; + // char StreetAddress[45] = {}; + // char City[35] = {}; + // char State[4] = {}; + // int Zip = 0; + // newContact.Set_a(0); + // //newContact.Set_id(i + 1); + // //newContact[i].count = t; + // cin.ignore(1000, '\n'); + // cout << "Please enter each piece of information when you are prompted to" << endl; + // cout << "enter first name: " << endl; + // cin >> firstName; + // newContact.Set_firstName(firstName); + // cout << "enter last name: " << endl; + // cin >> lastName; + // newContact.Set_lastName(lastName); + // cout << "enter Email: " << endl; + // cin >> Email; + // newContact.Set_email(Email); + // cout << "enter Street Address: " << endl; + // cin >> StreetAddress; + // newContact.Set_streetAddress(StreetAddress); + // cout << "enter city: " << endl; + // cin >> City; + // newContact.Set_city(City); + // cout << "enter State as two letter abbreviation: " << endl; + // cin >> State; + // newContact.Set_state(State); + // cout << "Please enter the next value as a series of numbers" << endl; + // cout << "enter Zip: " << endl; + // cin >> Zip; + // newContact.Set_zip(Zip); + // size_t id = i + 1; + // newContact.Set_id(id); + // newContact.print(); + // contacts.AddContact(newContact); + // break; + //} break; case 2: |