diff options
| author | Connor McDowell <[email protected]> | 2024-02-21 20:18:46 -0800 |
|---|---|---|
| committer | Connor McDowell <[email protected]> | 2024-02-21 20:18:46 -0800 |
| commit | 70e5cdf7d6274a7b1dd7e853820f86b502ee8b55 (patch) | |
| tree | db112077cb0b9d1f6a2d6f22f15ddae686b6990f | |
| parent | testing (diff) | |
| download | homework-6-connormcdowell275-70e5cdf7d6274a7b1dd7e853820f86b502ee8b55.tar.xz homework-6-connormcdowell275-70e5cdf7d6274a7b1dd7e853820f86b502ee8b55.zip | |
so close to being done oh my god
| -rw-r--r-- | Project1/contacts.cpp | 109 | ||||
| -rw-r--r-- | Project1/program.cpp | 2 |
2 files changed, 86 insertions, 25 deletions
diff --git a/Project1/contacts.cpp b/Project1/contacts.cpp index 95df50f..3d61730 100644 --- a/Project1/contacts.cpp +++ b/Project1/contacts.cpp @@ -22,6 +22,14 @@ char addNew(contact newContact[], size_t MAX, size_t& t) { for(newContact[i].a = 1; ++i;) { + newContact[i].a = 0; + for (auto j = newContact[i].id; j < MAX; j++) + { + if(newContact[i].id != 0) + { + i = i + 1; + } + } newContact[i].id = i; newContact[i].count = t; cin.ignore(1000, '\n'); @@ -44,6 +52,7 @@ char addNew(contact newContact[], size_t MAX, size_t& t) } for (size_t i = t ; i < MAX; i++) { + newContact[i].a = 0; newContact[i].id = i+1; newContact[i].count = t; cin.ignore(1000, '\n'); @@ -115,6 +124,10 @@ void printAll(contact newContact[], size_t& MAX) /*for (int t = -1; t < newContact[i].id;) { break; }*/ + if (newContact[i].a == 1) + { + i = i + 1; + } if (newContact[i].id == 0) { break; } @@ -124,14 +137,7 @@ void printAll(contact newContact[], size_t& MAX) if (newContact[i].id > MAX) { break; } - if(newContact[i].a == 0) - { - continue; - } - //if (newContact[i].a == 1) - //{ - // break; - //} + cout << "List number: " << newContact[i].id << endl; cout << "name: " << newContact[i].Name << endl; @@ -198,10 +204,10 @@ void delete_contact(contact newContact[], size_t MAX) { //Work in progress, add BOOL (true) to struct, when this is selected print id list with respective names //then take input of id list number and set bool to false - //add to new part to addNew: if bool != 0 then copy and paste update code w/addNew couts + //add to new part to addNew: if bool != 0 then copy and paste update code w/addNew couts cout << "The list of contacts and their names will now print" << endl; - for (auto i = 0u; i <= MAX; i++) - { + for (auto i = 0u; i < MAX; i++) + { if (newContact[i].id == 0) { break; } @@ -216,19 +222,74 @@ void delete_contact(contact newContact[], size_t MAX) // break; //} cout << "Id number: " << newContact[i].id << " is under the name: " << newContact[i].Name << endl; - } - size_t delete_choice = 0; - cout << "\n"; - cin.ignore(1000, '\n'); - cout << "Enter the id number of the contact you'd like to delete" << endl; - cin >> delete_choice; - for (auto i = 0u; i < MAX;) + //size_t delete_choice = 0; + //cout << "\n"; + //cin.ignore(1000, '\n'); + //cout << "Enter the id number of the contact you'd like to delete" << endl; + //cin >> delete_choice; + //if (delete_choice == newContact[i].id) + //{ + // newContact[i].a = 1; + // cout << "Contact number: " << newContact[i].id << " deleted" << endl; + // newContact[i + 1].id = newContact[i + 1].id - 1; + // break; + //} + } + for (int y = 0u; y < MAX; y++) { - if (delete_choice == newContact[i].id) - { - newContact[i].a = 1; - cout << "Contact number: " << newContact[i].id << " deleted" << endl; - break; - } + size_t delete_choice = 0; + cout << "\n"; + cin.ignore(1000, '\n'); + cout << "Enter the id number of the contact you'd like to delete" << endl; + cin >> delete_choice; + newContact[delete_choice].a = 1; + cout << "Contact number: " << newContact[delete_choice].id << " deleted" << endl; + newContact[delete_choice + 1].id = newContact[delete_choice + 1].id - 1; + break; } + + //for (auto i = 0u; i < MAX; i++) + //{ + // size_t delete_choice = 0; + // cout << "\n"; + // cin.ignore(1000, '\n'); + // cout << "Enter the id number of the contact you'd like to delete" << endl; + // cin >> delete_choice; + // if (delete_choice == newContact[delete_choice].id) + // { + // newContact[i].a = 1; + // cout << "Contact number: " << newContact[i].id << " deleted" << endl; + // newContact[i + 1].id = newContact[i + 1].id - 1; + // break; + // } + //} + //cout << "The list of contacts and their names will now print" << endl; + // for (auto i = 0u; i <= MAX; i++) + // { + // if (newContact[i].id == 0) { + // break; + // } + // if (newContact[i].id < 0) { + // break; + // } + // if (newContact[i].id > MAX) { + // break; + // } + // //if (newContact[i].a == 1) + // //{ + // // break; + // //} + // cout << "Id number: " << newContact[i].id << " is under the name: " << newContact[i].Name << endl; + // } + //size_t delete_choice = 0; + //cout << "\n"; + //cin.ignore(1000, '\n'); + //cout << "Enter the id number of the contact you'd like to delete" << endl; + //cin >> delete_choice; + // if (delete_choice == newContact[i].id) + // { + // newContact[i].a = 1; + // cout << "Contact number: " << newContact[i].id << " deleted" << endl; + // break; + // } }
\ No newline at end of file diff --git a/Project1/program.cpp b/Project1/program.cpp index 9c134fb..bf4faae 100644 --- a/Project1/program.cpp +++ b/Project1/program.cpp @@ -51,7 +51,7 @@ int main() update(newContact, MAX); break; case 3: - printAll(newContact, t); // Print only the existing contacts + printAll(newContact, MAX); // Print only the existing contacts break; case 4: delete_contact(newContact, MAX); |