diff options
| author | Miles-Cell <[email protected]> | 2024-02-12 11:48:57 -0800 |
|---|---|---|
| committer | Miles-Cell <[email protected]> | 2024-02-12 11:48:57 -0800 |
| commit | da6213961791035ef586e3593150e8fb26d9f370 (patch) | |
| tree | 8cc703374754589a71b2af6bb0e1b5810b47f983 | |
| parent | Created Contacts.cpp, Contacts.h, refining script... making changes to errors. (diff) | |
| download | homework-5-miles-cell-da6213961791035ef586e3593150e8fb26d9f370.tar.xz homework-5-miles-cell-da6213961791035ef586e3593150e8fb26d9f370.zip | |
Updated code. Assignment not completed yet.
| -rw-r--r-- | Homework 5/Homework 5/Contacts.cpp | 42 | ||||
| -rw-r--r-- | Homework 5/Homework 5/Contacts.h | 8 | ||||
| -rw-r--r-- | Homework 5/Homework 5/program.cpp | 67 |
3 files changed, 67 insertions, 50 deletions
diff --git a/Homework 5/Homework 5/Contacts.cpp b/Homework 5/Homework 5/Contacts.cpp index 2809a71..e93358b 100644 --- a/Homework 5/Homework 5/Contacts.cpp +++ b/Homework 5/Homework 5/Contacts.cpp @@ -1,21 +1,45 @@ #include <iostream> #include "Contacts.h" +using std::cout; +using std::cin; +using std::endl; -#include <vector> +Contact InputNewContacts() +{ + Contact newContact = {}; + cout << "Name: "; + cin >> newContact.Name; + cout << "Email: "; + cin >> newContact.Email; -// Function definitions -void addNewContact(std::vector<Contact>& contacts) { - // Implementation for adding a new contact -} + cout << "Street Address: "; + cin >> newContact.StreetAddress; + + cout << "City: "; + cin >> newContact.City; + + cout << "State: "; + cin >> newContact.State; + + cout << "Zip: "; + cin >> newContact.Zip; -void updateContact(std::vector<Contact>& contacts) { - // Implementation for updating a given contact + return newContact; } -void printAllContacts(const std::vector<Contact>& contacts) { - // Implementation for printing all the contacts +void PrintContacts(Contact(&contacts)[10]) +{ + for (auto &x : contacts) + { + cout << "Name: " << x.Name << endl; + cout << "Email: " << x.Email << endl; + cout << "Street Address: " << x.StreetAddress << endl; + cout << "City: " << x.City << endl; + cout << "State: " << x.State << endl; + cout << "Zip: " << x.Zip << endl; + } } diff --git a/Homework 5/Homework 5/Contacts.h b/Homework 5/Homework 5/Contacts.h index 8654303..eadf34d 100644 --- a/Homework 5/Homework 5/Contacts.h +++ b/Homework 5/Homework 5/Contacts.h @@ -1,8 +1,6 @@ #ifndef CONTACTS_H #define CONTACTS_H -#include <Vector> - struct Contact { @@ -15,8 +13,8 @@ struct Contact }; -void addNewContact(std::vector<Contact>& contacts); -void updateContact(std::vector<Contact>& contacts); -void printAllContacts(const std::vector<Contact>& contacts); +Contact InputNewContacts(); + +void PrintContacts(Contact(&contacts)[10]); #endif // !CONTACTS_H diff --git a/Homework 5/Homework 5/program.cpp b/Homework 5/Homework 5/program.cpp index 960e5be..f488216 100644 --- a/Homework 5/Homework 5/program.cpp +++ b/Homework 5/Homework 5/program.cpp @@ -4,56 +4,51 @@ // Assignment: Homework 5 -#include "Contacts.h" -#include <vector> + #include <iostream> +#include <cstdlib> -int main() -{ - std::vector<Contact> contacts; - int choice = 0; +using std::cout; +using std::cin; +using std::endl; - struct Contact - { +const int MAX = 10; - char Name[25] = {}; - char Email[100] = {}; - char StreetAddress[35] = {}; - char City[30] = {}; - char State[25] = {}; - int Zip = 0; - }; +int main() +{ +#include "Contacts.h" + Contact contacts[MAX] = {}; + int numberOfContacts = 0; - do - { - std::cout << "\nMenu:\n"; - std::cout << "1. Add New Contact\n"; - std::cout << "2. Update Contact\n"; - std::cout << "3. Print All Contacts\n"; - std::cout << "4. Exit\n"; - std::cout << "Enter your choice: "; - std::cin >> choice; + char c = 'n'; - switch (choice) + do { + system("cls"); + cout << "A: Input New Contact\n"; + cout << "B: Update Contact\n"; + cout << "C: Print Contacts\n"; + cout << "Press 'x' to Exit\n"; + + std::cin >> c; + switch (c) { - case 1: - addNewContact(contacts); + case 'A': + //do stuff = New contact added to array break; - case 2: - updateContact(contacts); + case 'B': + //Pick a contact, then update with new info; break; - case 3: - printAllContacts(contacts); + case 'C': + //Print the contacts break; - case 4: - std::cout << "Exiting...\n"; + case 'x': + //exit break; default: - std::cout << "Invalid choice, please try again.\n"; + cout << "\nThat was a bad input\n"; } - } while (choice != 4); - + } while (c != 'x'); return 0; } |