aboutsummaryrefslogtreecommitdiff
path: root/Project1
diff options
context:
space:
mode:
authorConnor McDowell <[email protected]>2024-02-21 19:23:11 -0800
committerConnor McDowell <[email protected]>2024-02-21 19:23:11 -0800
commit0557774b1e8e0124768aa03f24bda5c76dfc8c44 (patch)
treee6baac6db2fdcb5a5e6ac6570681f239d57deaa6 /Project1
parentstart: finishing delete and assignment (diff)
downloadhomework-6-connormcdowell275-0557774b1e8e0124768aa03f24bda5c76dfc8c44.tar.xz
homework-6-connormcdowell275-0557774b1e8e0124768aa03f24bda5c76dfc8c44.zip
testing
Diffstat (limited to 'Project1')
-rw-r--r--Project1/Contacts.h4
-rw-r--r--Project1/contacts.cpp68
-rw-r--r--Project1/program.cpp3
3 files changed, 69 insertions, 6 deletions
diff --git a/Project1/Contacts.h b/Project1/Contacts.h
index 7a4f091..4ce76c4 100644
--- a/Project1/Contacts.h
+++ b/Project1/Contacts.h
@@ -7,7 +7,7 @@
struct contact
{
- bool a = true;
+ int a = 0;
size_t id = 0;
size_t count = 0;
char Name[30];
@@ -45,6 +45,6 @@ contact contact_double(contact*& newContact, size_t& MAX, size_t t);
size_t max_double(size_t MAX);
-void delete_contact(contact newContact[]);
+void delete_contact(contact newContact[], size_t MAX);
#endif CONTACTS_HEADER_H \ No newline at end of file
diff --git a/Project1/contacts.cpp b/Project1/contacts.cpp
index 67bed22..95df50f 100644
--- a/Project1/contacts.cpp
+++ b/Project1/contacts.cpp
@@ -18,6 +18,30 @@ char addNew(contact newContact[], size_t MAX, size_t& t)
// void mod_update
// to check for any "empty"/deleted contacts before adding one. if bool == false should include break after mod_update.
//CURRENTLY WORKS
+ for (size_t i = 0; i < MAX, i++;)
+ {
+ for(newContact[i].a = 1; ++i;)
+ {
+ newContact[i].id = i;
+ newContact[i].count = t;
+ cin.ignore(1000, '\n');
+ cout << "Please enter each piece of information when you are prompted to" << endl;
+ cout << "enter name: " << endl;
+ cin.getline(newContact[i].Name, 25);
+ cout << "enter Email: " << endl;
+ cin.getline(newContact[i].Email, 100);
+ cout << "enter Street Address: " << endl;
+ cin.getline(newContact[i].StreetAddress, 35);
+ cout << "enter city: " << endl;
+ cin.getline(newContact[i].City, 30);
+ cout << "enter State as two letter abbreviation: " << endl;
+ cin.getline(newContact[i].State, 3);
+ cout << "Please enter the next value as a series of numbers" << endl;
+ cout << "enter Zip: " << endl;
+ cin >> newContact[i].Zip;
+ break;
+ }
+ }
for (size_t i = t ; i < MAX; i++)
{
newContact[i].id = i+1;
@@ -100,6 +124,14 @@ 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;
@@ -162,9 +194,41 @@ size_t max_double(size_t MAX)
return MAX;
}
-void delete_contact(contact newContact[])
+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++)
+ {
+ 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;
+ for (auto i = 0u; i < MAX;)
+ {
+ 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 a75931b..9c134fb 100644
--- a/Project1/program.cpp
+++ b/Project1/program.cpp
@@ -37,7 +37,6 @@ int main()
{
case 1:
addNew(newContact, MAX, t);
- ++t;
if (t >= MAX) // Check if the number of contacts exceeds MAX
{
contact* newContactTemp = new contact[MAX * 2]; // Double the size
@@ -55,7 +54,7 @@ int main()
printAll(newContact, t); // Print only the existing contacts
break;
case 4:
- delete_contact(newContact);
+ delete_contact(newContact, MAX);
break;
case 5:
O = 0;