aboutsummaryrefslogtreecommitdiff
path: root/Project1/contacts.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Project1/contacts.cpp')
-rw-r--r--Project1/contacts.cpp135
1 files changed, 86 insertions, 49 deletions
diff --git a/Project1/contacts.cpp b/Project1/contacts.cpp
index c393b8e..917d085 100644
--- a/Project1/contacts.cpp
+++ b/Project1/contacts.cpp
@@ -128,7 +128,7 @@ char addNew(contact newContact[], size_t MAX, size_t& t)
//if (bool == false)
// void mod_update
// to check for any "empty"/deleted contacts before adding one. if bool == false should include break after mod_update.
- //CURRENTLY WORKS
+ //CURRENTLY TESTING
for (size_t i = 0; i < MAX, i++;)
{
int a = newContact[i].Get_a();
@@ -151,7 +151,7 @@ char addNew(contact newContact[], size_t MAX, size_t& t)
char State[4];
int Zip = 0;
newContact[i].Set_id(i);
- newContact[i].Set_a(t);
+ //newContact[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;
@@ -181,24 +181,40 @@ 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;
+ char firstName[30];
+ char lastName[30];
+ char Email[105];
+ char StreetAddress[45];
+ char City[35];
+ char State[4];
+ int Zip = 0;
+ newContact[i].Set_a(0);
+ newContact[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 name: " << endl;
- cin.getline(newContact[i].Name, 25);
+ cout << "enter first name: " << endl;
+ cin >> firstName;
+ newContact[i].Set_firstName(firstName);
+ cout << "enter last name: " << endl;
+ cin >> lastName;
+ newContact[i].Set_lastName(lastName);
cout << "enter Email: " << endl;
- cin.getline(newContact[i].Email, 100);
+ cin >> Email;
+ newContact[i].Set_email(Email);
cout << "enter Street Address: " << endl;
- cin.getline(newContact[i].StreetAddress, 35);
+ cin >> StreetAddress;
+ newContact[i].Set_streetAddress(StreetAddress);
cout << "enter city: " << endl;
- cin.getline(newContact[i].City, 30);
+ cin >> City;
+ newContact[i].Set_city(City);
cout << "enter State as two letter abbreviation: " << endl;
- cin.getline(newContact[i].State, 3);
+ cin >> State;
+ newContact[i].Set_state(State);
cout << "Please enter the next value as a series of numbers" << endl;
cout << "enter Zip: " << endl;
- cin >> newContact[i].Zip;
+ cin >> Zip;
+ newContact[i].Set_zip(Zip);
t++;
break;
}
@@ -207,20 +223,29 @@ char addNew(contact newContact[], size_t MAX, size_t& t)
return 0;
}
-void contact_list::AddContact(const contact& contact)
-{
- size_t length = contact_list::length_;
- for (size_t i = 0; i < length, i++;)
- {
-
- }
+// important below. may need if current testing doesnt work.
-}
+//void contact_list::AddContact(const contact& contact)
+//{
+// size_t length = contact_list::length_;
+// for (size_t i = 0; i < length, i++;)
+// {
+//
+// }
+//
+//}
void update(contact newContact[], size_t MAX)
{
//uses input based on list number from print (though when delete is made will be using that id/name print) to update the values of.
- //CURRENTLY WORKING
+ //CURRENTLY TESTING
+ char firstName[30];
+ char lastName[30];
+ char Email[105];
+ char StreetAddress[45];
+ char City[35];
+ char State[4];
+ int Zip = 0;
cout << "select a contact to update based on their position in the list (check print all contacts for list position)" << endl;
int c = 0;
cin >> c;
@@ -229,20 +254,29 @@ void update(contact newContact[], size_t MAX)
{
cin.ignore(1000, '\n');
cout << "Please enter each piece of information when you are prompted to" << endl;
- newContact[i].id = c;
- cout << "enter name: " << endl;
- cin.getline(newContact[i].Name, 25);
+ newContact[i].Set_id(c);
+ cout << "enter first name: " << endl;
+ cin >> firstName;
+ newContact[i].Set_firstName(firstName);
+ cout << "enter last name: " << endl;
+ cin >> lastName;
+ newContact[i].Set_lastName(lastName);
cout << "enter Email: " << endl;
- cin.getline(newContact[i].Email, 100);
+ cin >> Email;
+ newContact[i].Set_email(Email);
cout << "enter Street Address: " << endl;
- cin.getline(newContact[i].StreetAddress, 35);
+ cin >> StreetAddress;
+ newContact[i].Set_streetAddress(StreetAddress);
cout << "enter city: " << endl;
- cin.getline(newContact[i].City, 30);
+ cin >> City;
+ newContact[i].Set_city(City);
cout << "enter State as two letter abbreviation: " << endl;
- cin.getline(newContact[i].State, 3);
+ cin >> State;
+ newContact[i].Set_state(State);
cout << "Please enter the next value as a series of numbers" << endl;
cout << "enter Zip: " << endl;
- cin >> newContact[i].Zip;
+ cin >> Zip;
+ newContact[i].Set_zip(Zip);
break;
}
}
@@ -256,28 +290,31 @@ void printAll(contact newContact[], size_t& MAX)
/*for (int t = -1; t < newContact[i].id;) {
break;
}*/
- if (newContact[i].a == 1)
+ size_t existing = newContact[i].Get_a();
+ size_t verify = newContact[i].Get_id();
+ if (existing == 1)
{
i = i + 1;
}
- if (newContact[i].id == 0) {
+ if (verify == 0) {
break;
}
- if (newContact[i].id < 0) {
+ if (verify < 0) {
break;
}
- if (newContact[i].id > MAX) {
+ if (verify > MAX) {
break;
}
- cout << "List number: " << newContact[i].id << endl;
- cout << "name: " << newContact[i].Name << endl;
- cout << "Email: " << newContact[i].Email << endl;
- cout << "Address: " << newContact[i].StreetAddress << endl;
- cout << "city: " << newContact[i].City << endl;
- cout << "state: " << newContact[i].State << endl;
- cout << "Zip: " << newContact[i].Zip << endl;
+ cout << "List number: " << newContact[i].Get_id() << endl;
+ cout << "First name: " << newContact[i].Get_firstName() << endl;
+ cout << "Last name: " << newContact[i].Get_lastName();
+ cout << "Email: " << newContact[i].Get_email() << endl;
+ cout << "Address: " << newContact[i].Get_streetAddress() << endl;
+ cout << "city: " << newContact[i].Get_city() << endl;
+ cout << "state: " << newContact[i].Get_state() << endl;
+ cout << "Zip: " << newContact[i].Get_zip() << endl;
}
}
@@ -340,20 +377,20 @@ void delete_contact(contact newContact[], size_t MAX)
cout << "The list of contacts and their names will now print" << endl;
for (auto i = 0u; i < MAX; i++)
{
- if (newContact[i].id == 0) {
+ if (newContact[i].Get_id() == 0) {
break;
}
- if (newContact[i].id < 0) {
+ if (newContact[i].Get_id() < 0) {
break;
}
- if (newContact[i].id > MAX) {
+ if (newContact[i].Get_id() > MAX) {
break;
}
//if (newContact[i].a == 1)
//{
// break;
//}
- cout << "Id number: " << newContact[i].id << " is under the name: " << newContact[i].Name << endl;
+ cout << "Id number: " << newContact[i].Get_id() << " is under the name: " << newContact[i].Get_firstName() << " " << newContact[i].Get_lastName() << endl;
//size_t delete_choice = 0;
//cout << "\n";
//cin.ignore(1000, '\n');
@@ -374,15 +411,15 @@ void delete_contact(contact newContact[], size_t MAX)
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)
+ if (delete_choice != newContact[i].Get_id())
{
i = i + 1;
}
- if (delete_choice == newContact[i].id)
+ if (delete_choice == newContact[i].Get_id())
{
- newContact[i].a = 1;
- cout << "Contact number: " << newContact[i].id << " deleted" << endl;
- newContact[i + 1].id = newContact[i + 1].id - 1;
+ newContact[i].Set_a(1);
+ cout << "Contact number: " << newContact[i].Get_id() << " deleted" << endl;
+ newContact[i + 1].Set_id(i - 1);
break;
}
}