aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConnor McDowell <[email protected]>2024-03-03 15:50:31 -0800
committerConnor McDowell <[email protected]>2024-03-03 15:50:31 -0800
commit72ea23746ded387b0a411eac30be4ed32b6eadb0 (patch)
treeaec2c7e9eead9e18990f35a51528256925277fc2
parenttemp refactored add. still needs cleaning (diff)
downloadhomework-7-connormcdowell275-72ea23746ded387b0a411eac30be4ed32b6eadb0.tar.xz
homework-7-connormcdowell275-72ea23746ded387b0a411eac30be4ed32b6eadb0.zip
add new mostly working, will need to tweek counter variable to work with classes
print works
-rw-r--r--Project1/Contact_list.h2
-rw-r--r--Project1/contacts.cpp94
2 files changed, 40 insertions, 56 deletions
diff --git a/Project1/Contact_list.h b/Project1/Contact_list.h
index 18348a1..44576ad 100644
--- a/Project1/Contact_list.h
+++ b/Project1/Contact_list.h
@@ -37,7 +37,7 @@ public:
size_t Size() const;
- void Update(contact newContact, size_t MAX);
+ void Update(const contact& contact);
};
diff --git a/Project1/contacts.cpp b/Project1/contacts.cpp
index 4de1d59..2d800e0 100644
--- a/Project1/contacts.cpp
+++ b/Project1/contacts.cpp
@@ -143,6 +143,17 @@ size_t contact::Get_id()
return _id;
}
+void contact::print()
+{
+ cout << "Full name: " << _firstName << " " << _lastName << endl;
+ cout << "Street Address: " << _streetAddress << endl;
+ cout << "City: " << _city << endl;
+ cout << "State: " << _state << endl;
+ cout << "Zip code: " << _zip << endl;
+ cout << "Email: " << _email << endl;
+
+}
+
//functions
void contact_list::AddContact(const contact& contact)
{
@@ -150,14 +161,14 @@ void contact_list::AddContact(const contact& contact)
//CURRENTLY TESTING
for (size_t i = 0; i < size_, i++;)
{
- int a = contact.Get_a();
+ size_t a = contacts_[i].Get_a();
for (a = 1; ++i;)
{
- contact.Set_a(0);
- int temp = contact[i].Get_id();
+ contacts_[i].Set_a(0);
+ size_t temp = contacts_[i].Get_id();
for (auto j = temp; j < size_; j++)
{
- if (contact.Get_id() != 0)
+ if (contacts_[i].Get_id() != 0)
{
i = i + 1;
}
@@ -169,36 +180,36 @@ void contact_list::AddContact(const contact& contact)
char City[35];
char State[4];
int Zip = 0;
- contact.Set_id(i);
- //newContact[i].Set_a(t);
+ 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;
- contact.Set_firstName(firstName);
+ contacts_[i].Set_firstName(firstName);
cout << "enter last name: " << endl;
cin >> lastName;
- contact.Set_lastName(lastName);
+ contacts_[i].Set_lastName(lastName);
cout << "enter Email: " << endl;
cin >> Email;
- contact.Set_email(Email);
+ contacts_[i].Set_email(Email);
cout << "enter Street Address: " << endl;
cin >> StreetAddress;
- contact.Set_streetAddress(StreetAddress);
+ contacts_[i].Set_streetAddress(StreetAddress);
cout << "enter city: " << endl;
cin >> City;
- contact.Set_city(City);
+ contacts_[i].Set_city(City);
cout << "enter State as two letter abbreviation: " << endl;
cin >> State;
- contact.Set_state(State);
+ contacts_[i].Set_state(State);
cout << "Please enter the next value as a series of numbers" << endl;
cout << "enter Zip: " << endl;
cin >> Zip;
- contact.Set_zip(Zip);
+ contacts_[i].Set_zip(Zip);
break;
}
}
- for (size_t i = t; i < MAX; i++)
+ for (size_t i = t; i < size_; i++)
{
char firstName[30];
char lastName[30];
@@ -207,33 +218,33 @@ void contact_list::AddContact(const contact& contact)
char City[35];
char State[4];
int Zip = 0;
- contact.Set_a(0);
- contact.Set_id(i + 1);
+ 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;
- contact.Set_firstName(firstName);
+ contacts_[i].Set_firstName(firstName);
cout << "enter last name: " << endl;
cin >> lastName;
- contact.Set_lastName(lastName);
+ contacts_[i].Set_lastName(lastName);
cout << "enter Email: " << endl;
cin >> Email;
- contact.Set_email(Email);
+ contacts_[i].Set_email(Email);
cout << "enter Street Address: " << endl;
cin >> StreetAddress;
- contact.Set_streetAddress(StreetAddress);
+ contacts_[i].Set_streetAddress(StreetAddress);
cout << "enter city: " << endl;
cin >> City;
- contact.Set_city(City);
+ contacts_[i].Set_city(City);
cout << "enter State as two letter abbreviation: " << endl;
cin >> State;
- contact.Set_state(State);
+ contacts_[i].Set_state(State);
cout << "Please enter the next value as a series of numbers" << endl;
cout << "enter Zip: " << endl;
cin >> Zip;
- contact.Set_zip(Zip);
+ contacts_[i].Set_zip(Zip);
t++;
break;
}
@@ -243,7 +254,7 @@ void contact_list::AddContact(const contact& contact)
}
-void contact_list::Update(contact newContact, size_t MAX)
+void contact_list::Update(const contact& contact)
{
//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 TESTING
@@ -258,7 +269,7 @@ void contact_list::Update(contact newContact, size_t MAX)
int c = 0;
cin >> c;
int t = c - 1;
- for (size_t i = t; i < MAX;)
+ for (size_t i = t; i < size_;)
{
cin.ignore(1000, '\n');
cout << "Please enter each piece of information when you are prompted to" << endl;
@@ -289,40 +300,13 @@ void contact_list::Update(contact newContact, size_t MAX)
}
}
-void contact_list::Print(contact newContact[], size_t& MAX) const
+void contact_list::Print() const
{
//prints all info but count and bool for every existing (non trash value filled) contact struct
//CURRENTLY WORKING
- for (size_t i = 0; i <= MAX; ++i)
+ for (auto i = 0u; i < size_; ++i)
{
- /*for (int t = -1; t < newContact[i].id;) {
- break;
- }*/
- size_t existing = newContact[i].Get_a();
- size_t verify = newContact[i].Get_id();
- if (existing == 1)
- {
- i = i + 1;
- }
- if (verify == 0) {
- break;
- }
- if (verify < 0) {
- break;
- }
- if (verify > MAX) {
- break;
- }
-
-
- 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;
+ contacts_[i].print;
}
}