aboutsummaryrefslogtreecommitdiff
path: root/Project1
diff options
context:
space:
mode:
authorConnor McDowell <[email protected]>2024-03-03 16:12:05 -0800
committerConnor McDowell <[email protected]>2024-03-03 16:12:05 -0800
commit979fcacec2a512ed7a66208cc47d894b7c0cebe7 (patch)
treeb7677c371c10065b779f22e1e0c0aa391ac64d6e /Project1
parentdelete refactored (diff)
downloadhomework-7-connormcdowell275-979fcacec2a512ed7a66208cc47d894b7c0cebe7.tar.xz
homework-7-connormcdowell275-979fcacec2a512ed7a66208cc47d894b7c0cebe7.zip
first successful build
Diffstat (limited to 'Project1')
-rw-r--r--Project1/Contact_list.h2
-rw-r--r--Project1/Contacts.h3
-rw-r--r--Project1/contacts.cpp237
-rw-r--r--Project1/program.cpp10
4 files changed, 110 insertions, 142 deletions
diff --git a/Project1/Contact_list.h b/Project1/Contact_list.h
index 44576ad..2338bf7 100644
--- a/Project1/Contact_list.h
+++ b/Project1/Contact_list.h
@@ -35,8 +35,6 @@ public:
void Print() const;
- size_t Size() const;
-
void Update(const contact& contact);
};
diff --git a/Project1/Contacts.h b/Project1/Contacts.h
index e29d5f0..5d53b89 100644
--- a/Project1/Contacts.h
+++ b/Project1/Contacts.h
@@ -16,9 +16,6 @@ public:
contact(contact&& move);
contact& operator=(contact&& rhs);*/
- int Get_index();
- void Set_index(int id);
-
const char* Get_firstName();
void Set_firstName(const char* firstName);
diff --git a/Project1/contacts.cpp b/Project1/contacts.cpp
index 4cbdd2d..ee12f96 100644
--- a/Project1/contacts.cpp
+++ b/Project1/contacts.cpp
@@ -116,15 +116,6 @@ size_t contact_list::get_size()
return size_;
}
-void contact::Set_index(int id)
-{
- _id = id;
-}
-int contact::Get_index()
-{
- return _id;
-}
-
void contact::Set_a(size_t a)
{
_a = a;
@@ -210,96 +201,101 @@ void contact_list::AddContact(const contact& contact)
break;
}
}
- for (size_t i = t; i < size_; i++)
+ for (auto i = 0u; 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);
- t++;
- break;
+ size_t t = contacts_[i].Get_id();
+ for (size_t i = t; 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);
+ t++;
+ 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;
}
-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
- 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;
- int t = c - 1;
- for (size_t i = t; i < size_;)
- {
- cin.ignore(1000, '\n');
- cout << "Please enter each piece of information when you are prompted to" << endl;
- 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 >> Email;
- newContact[i].Set_email(Email);
- cout << "enter Street Address: " << endl;
- cin >> StreetAddress;
- newContact[i].Set_streetAddress(StreetAddress);
- cout << "enter city: " << endl;
- cin >> City;
- newContact[i].Set_city(City);
- cout << "enter State as two letter abbreviation: " << endl;
- cin >> State;
- newContact[i].Set_state(State);
- cout << "Please enter the next value as a series of numbers" << endl;
- cout << "enter Zip: " << endl;
- cin >> Zip;
- newContact[i].Set_zip(Zip);
- break;
- }
-}
+//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
+// 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;
+// int t = c - 1;
+// for (size_t i = t; i < size_;)
+// {
+// cin.ignore(1000, '\n');
+// cout << "Please enter each piece of information when you are prompted to" << endl;
+// 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 >> Email;
+// newContact[i].Set_email(Email);
+// cout << "enter Street Address: " << endl;
+// cin >> StreetAddress;
+// newContact[i].Set_streetAddress(StreetAddress);
+// cout << "enter city: " << endl;
+// cin >> City;
+// newContact[i].Set_city(City);
+// cout << "enter State as two letter abbreviation: " << endl;
+// cin >> State;
+// newContact[i].Set_state(State);
+// cout << "Please enter the next value as a series of numbers" << endl;
+// cout << "enter Zip: " << endl;
+// cin >> Zip;
+// newContact[i].Set_zip(Zip);
+// break;
+// }
+//}
void contact_list::Print() const
{
@@ -307,7 +303,7 @@ void contact_list::Print() const
//CURRENTLY WORKING
for (auto i = 0u; i < size_; ++i)
{
- contacts_[i].print;
+ contacts_[i].print();
}
}
@@ -366,7 +362,7 @@ void contact_list::DeleteContact(contact& contact)
{
//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 < size_; i++)
{
@@ -399,56 +395,33 @@ void contact_list::DeleteContact(contact& contact)
}
for (auto i = 0u; i < size_; 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;
+ 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 != contacts_[i].Get_id())
{
i = i + 1;
}
- if (delete_choice == contacts_[i].Get_id())
- {
+ if (delete_choice == contacts_[i].Get_id())
+ {
contacts_[i].Set_a(1);
contacts_[i + 1].Set_id(i - 1);
- break;
- }
+ 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;
- // }
}
void contact_list::CopyList(const contact* contacts, const size_t& size)
{
-
+ length_ = size;
+ contacts_ = allocateContactList(size);
+
+ for(auto i = 0u; i < size; ++i)
+ {
+ contacts_[i] = contacts[i];
+ }
}
diff --git a/Project1/program.cpp b/Project1/program.cpp
index d6761d5..4029c61 100644
--- a/Project1/program.cpp
+++ b/Project1/program.cpp
@@ -49,17 +49,17 @@ int main()
// newContact = newContactTemp; // Update pointer
// MAX *= 2; // Update MAX
//}
-
break;
case 2:
- contacts.Update(newContact, MAX);
+ //contacts.Update(newContact);
+ cout << "this program is currently a work in progress" << endl;
break;
case 3:
- contacts.Print(&newContact, MAX); // Print only the existing contacts
+ contacts.Print(); // Print only the existing contacts
break;
case 4:
- contacts.DeleteContact(&newContact, MAX);
- contacts.CopyList(&newContact, MAX);
+ contacts.DeleteContact(newContact);
+ //contacts.CopyList(&newContact, MAX);
break;
case 5:
O = 0;