diff options
| author | Connor McDowell <[email protected]> | 2024-03-04 18:31:25 -0800 |
|---|---|---|
| committer | Connor McDowell <[email protected]> | 2024-03-04 18:31:25 -0800 |
| commit | 2dd34978047a0602f89417343c69e8701c3c63a4 (patch) | |
| tree | 0b9396f18138a6b2e1c8103c35d78b4d91f2c403 /Project1 | |
| parent | tested potiential issue, did not fix (diff) | |
| download | homework-7-connormcdowell275-2dd34978047a0602f89417343c69e8701c3c63a4.tar.xz homework-7-connormcdowell275-2dd34978047a0602f89417343c69e8701c3c63a4.zip | |
exception fixed
Diffstat (limited to 'Project1')
| -rw-r--r-- | Project1/Contact_list.h | 2 | ||||
| -rw-r--r-- | Project1/Contacts.h | 24 | ||||
| -rw-r--r-- | Project1/contacts.cpp | 32 | ||||
| -rw-r--r-- | Project1/program.cpp | 17 |
4 files changed, 46 insertions, 29 deletions
diff --git a/Project1/Contact_list.h b/Project1/Contact_list.h index 81dddaf..46b4b07 100644 --- a/Project1/Contact_list.h +++ b/Project1/Contact_list.h @@ -31,7 +31,7 @@ public: void CopyList(const contact* contacts, const size_t& size); - void AddContact(const contact& contact); + void AddContact(contact& contact); void Print() const; diff --git a/Project1/Contacts.h b/Project1/Contacts.h index 5d53b89..fa2cad9 100644 --- a/Project1/Contacts.h +++ b/Project1/Contacts.h @@ -17,25 +17,25 @@ public: contact& operator=(contact&& rhs);*/ const char* Get_firstName(); - void Set_firstName(const char* firstName); + void Set_firstName(char* firstName); const char* Get_lastName(); - void Set_lastName(const char* lastName); + void Set_lastName(char* lastName); const char* Get_streetAddress(); - void Set_streetAddress(const char* streetAddress); + void Set_streetAddress(char* streetAddress); const char* Get_city(); - void Set_city(const char* city); + void Set_city(char* city); const char* Get_state(); - void Set_state(const char* state); + void Set_state(char* state); int Get_zip(); void Set_zip(int zip); const char* Get_email(); - void Set_email(const char* email); + void Set_email(char* email); size_t Get_a(); void Set_a(size_t a); @@ -49,13 +49,13 @@ private: size_t _a = 0; // _a functions as delete bool. if a = 1, the slot is overwritten int _id; - const char* _firstName{ }; - const char* _lastName{ }; - const char* _streetAddress{ }; - const char* _city{ }; - const char* _state{ }; + char* _firstName{ }; + char* _lastName{ }; + char* _streetAddress{ }; + char* _city{ }; + char* _state{ }; int _zip; - const char* _email{ }; + char* _email{ }; }; diff --git a/Project1/contacts.cpp b/Project1/contacts.cpp index d7ce25c..e380479 100644 --- a/Project1/contacts.cpp +++ b/Project1/contacts.cpp @@ -35,7 +35,7 @@ contact_list::contact_list(const size_t& size) //getters n setters -void contact::Set_firstName(const char* firstName) +void contact::Set_firstName(char* firstName) { _firstName = firstName; } @@ -44,7 +44,7 @@ const char* contact::Get_firstName() return _firstName; } -void contact::Set_lastName(const char* lastName) +void contact::Set_lastName(char* lastName) { _lastName = lastName; } @@ -53,7 +53,7 @@ const char* contact::Get_lastName() return _lastName; } -void contact::Set_streetAddress(const char* streetAddress) +void contact::Set_streetAddress(char* streetAddress) { _streetAddress = streetAddress; } @@ -62,7 +62,7 @@ const char* contact::Get_streetAddress() return _streetAddress; } -void contact::Set_city(const char* city) +void contact::Set_city(char* city) { _city = city; } @@ -71,7 +71,7 @@ const char* contact::Get_city() return _city; } -void contact::Set_state(const char* state) +void contact::Set_state(char* state) { _state = state; } @@ -89,7 +89,7 @@ int contact::Get_zip() return _zip; } -void contact::Set_email(const char* email) +void contact::Set_email(char* email) { _email = email; } @@ -191,9 +191,9 @@ void addContact(contact newContact, size_t MAX, contact_list contacts[]) } } -void contact_list::AddContact(const contact& newContact) +void contact_list::AddContact(contact& Contact) { - contacts_[size_++] = newContact; + contacts_[size_++] = Contact; //CURRENTLY TESTING //for (size_t i = 0; i < size_, i++;) //{ @@ -343,6 +343,22 @@ void contact_list::Print() const //CURRENTLY WORKING for (auto i = 0u; i < size_; ++i) { + + size_t check = 1; + + if (contacts_[i].Get_id() == check) + { + i = i + 1; + } + if (contacts_[i].Get_id() == 0) { + break; + } + if (contacts_[i].Get_id() < 0) { + break; + } + if (contacts_[i].Get_id() > size_) { + break; + } contacts_[i].print(); } } diff --git a/Project1/program.cpp b/Project1/program.cpp index 5b28a17..50b0723 100644 --- a/Project1/program.cpp +++ b/Project1/program.cpp @@ -43,15 +43,15 @@ int main() //addContact(newContact, contacts.get_size(), contacts[MAX]); for (auto i = 0u; i < MAX; ++i) { - char firstName[30]; - char lastName[30]; - char Email[105]; - char StreetAddress[45]; - char City[35]; - char State[4]; + char firstName[30] = {}; + char lastName[30] = {}; + char Email[105] = {}; + char StreetAddress[45] = {}; + char City[35] = {}; + char State[4] = {}; int Zip = 0; newContact.Set_a(0); - newContact.Set_id(i + 1); + //newContact.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; @@ -80,9 +80,10 @@ int main() size_t id = i + 1; newContact.Set_id(id); newContact.print(); + contacts.AddContact(newContact); break; } - contacts.AddContact(newContact); + break; case 2: //contacts.Update(newContact); |