aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Hw-5/Hw-5/contacts.cpp64
-rw-r--r--Hw-5/Hw-5/contacts.h16
-rw-r--r--Hw-5/Hw-5/program.cpp62
3 files changed, 138 insertions, 4 deletions
diff --git a/Hw-5/Hw-5/contacts.cpp b/Hw-5/Hw-5/contacts.cpp
index 42af817..5a21028 100644
--- a/Hw-5/Hw-5/contacts.cpp
+++ b/Hw-5/Hw-5/contacts.cpp
@@ -1,7 +1,65 @@
#include <iostream>
+#include "contacts.h"
+using std::cout;
+using std::endl;
+using std::cin;
+
+
+
+contact InputNewcontact() {
+ contact newcontact = {};
+
+ cout << "Name: ";
+ cin >> newcontact.Name;
+
+ cout << "Email: ";
+ cin >> newcontact.Email;
+
+ cout << "StreetAddress: ";
+ cin >> newcontact.StreetAddress;
+
+ cout << "City: ";
+ cin >> newcontact.City;
+
+ cout << "State: ";
+ cin >> newcontact.State;
+
+ cout << "Zip: ";
+ cin >> newcontact.Zip;
+
+ newcontact.Delete = false;
+ return newcontact;
+}
+
+void Printcontacts(contact(&contacts)[10]) {
+ for (auto &x : contacts) {
+ if (!x.Delete)
+ {
+ cout << "Name: " << x.Name << endl;
+ cout << "Email: " << x.Email << endl;
+ cout << "StreetAddress: " << x.StreetAddress << endl;
+ cout << "City: " << x.City << endl;
+ cout << "State: " << x.State << endl;
+ cout << "Zip: " << x.Zip << endl;
+
+ }
+ //cout << endl;
+ }
+}
+
+void update(contact(&contacts)[10]) {
+ cout << "Print contact to update" << endl;
+
+ Printcontacts(contacts);
+ int num = 0;
+ cin >> num;
+
+
+ contacts[num] = InputNewcontact();
+
+
+ }
+
-int main() {
- return 0;
-} \ No newline at end of file
diff --git a/Hw-5/Hw-5/contacts.h b/Hw-5/Hw-5/contacts.h
index 834113a..44b962d 100644
--- a/Hw-5/Hw-5/contacts.h
+++ b/Hw-5/Hw-5/contacts.h
@@ -1,7 +1,23 @@
+
#ifndef CONTACTS_H
#define CONTACTS_H
+struct contact {
+ char Name[25] = {};
+ char Email[100] = {};
+ char StreetAddress[35] = {};
+ char City[30] = {};
+ char State[3] = {};
+ int Zip = 0;
+
+ bool Delete = true;
+ bool update = true;
+};
+
+contact InputNewcontact();
+void Printcontacts(contact(&contacts)[10]);
+void update(contact(&contacts)[10]);
#endif
diff --git a/Hw-5/Hw-5/program.cpp b/Hw-5/Hw-5/program.cpp
index 89f6c63..c976053 100644
--- a/Hw-5/Hw-5/program.cpp
+++ b/Hw-5/Hw-5/program.cpp
@@ -4,8 +4,68 @@
//Homework 5
#include <iostream>
+#include "contacts.h"
+#include <cstdlib>
+using std::cout;
+using std::cin;
+using std::endl;
+
+const int Max = 10;
+
+contact contacts[Max] = {};
+int numberofcontacts = 0;
+
+char c = 'n';
+
+
int main() {
+ do {
+ //system("cls");
+ cout << "A. Input New Contact\n";
+ cout << "B. Update contacts\n";
+ cout << "C. Print contacts\n";
+ cout << "press 'x' to exit\n";
+
+ std::cin >> c;
+ switch (c) {
+
+ case'A':
+
+ contacts[numberofcontacts++] = InputNewcontact();
+ /*
+ contact contact = InputNewcontact();
+ contacts[numberofcontacts] = contact;
+ numberofcontacts++;
+ */
+ break;
+ case 'B':
+ //pick contact then update new info
+ //print contacts with elemt
+ //prompt for user to input element
+ //pass that contact to a function to update
+ cout << "Print contact to update" << endl;
+ update(contacts);
+
+
+ break;
+ case'C':
+
+ Printcontacts(contacts);
+
+ break;
+ case 'x':
+ //exit
+ cout << "Goodbye";
+ break;
+ default:
+ cout << "That was bad input\n";
+ }
+
+ } while (c != 'x');
+
return 0;
-} \ No newline at end of file
+}
+
+