diff options
| author | rPatrickWarner <[email protected]> | 2024-03-04 17:11:54 -0800 |
|---|---|---|
| committer | rPatrickWarner <[email protected]> | 2024-03-04 17:11:54 -0800 |
| commit | e5eb6f396d9d7a959c45abf34a095a57b2295a24 (patch) | |
| tree | cd09a47418711839b533b90299f1b5cf11eb8e0f /Homework8/MyStructures/MenuHelper.hpp | |
| parent | init (diff) | |
| download | homework-8-reecepwarner-e5eb6f396d9d7a959c45abf34a095a57b2295a24.tar.xz homework-8-reecepwarner-e5eb6f396d9d7a959c45abf34a095a57b2295a24.zip | |
changes
Diffstat (limited to 'Homework8/MyStructures/MenuHelper.hpp')
| -rw-r--r-- | Homework8/MyStructures/MenuHelper.hpp | 149 |
1 files changed, 149 insertions, 0 deletions
diff --git a/Homework8/MyStructures/MenuHelper.hpp b/Homework8/MyStructures/MenuHelper.hpp new file mode 100644 index 0000000..81d11e0 --- /dev/null +++ b/Homework8/MyStructures/MenuHelper.hpp @@ -0,0 +1,149 @@ +#ifndef MENU_HELPER_HPP +#define MENU_HELPER_HPP + +#define _CRT_SECURE_NO_WARNINGS +#include "ContactList.hpp" + +using namespace MyStructures; + + +void MainMenu(); + +Contact InputContact(); + +char* PromptCharInput(const char* prompt, long long maxlen); + +int InputInt(const char* prompt); + +void PrintContact(ContactList<Contact>& contacts); + +Contact NewContact(); + +void PrintContact(ContactList<Contact>& contacts); + + + +void MainMenu() +{ + char Options = '\0'; + + + do + { + std::cout << "Welcome to the contacts menu\n" + << "1)Add New Contact\n" + << "2)Print All Contacts\n" + << "3)Delete Contact\n" + << "4)Exit\n"; + std::cin >> Options; + switch (Options) + { + case('1'): + + break; + case('2'): + //PrintContact(contacts); + break; + case('3'): + //contacts.DeleteContact("Which contact would you like to delete?", contacts); + break; + case('4'): + std::cout << "Thank you, have a great day!" << std::endl; + + break; + default: + std::cout << "Invalid Input, Try Again!" << std::endl; + } + + } while (Options != '4'); +} + +Contact InputContact() +{ + + + Contact newContact; + newContact.SetFirstName(PromptCharInput("What is your first name?", 101)); + + newContact.SetLastName(PromptCharInput("What is your last name?: ", 101)); + newContact.SetStreet(PromptCharInput("What is your street address?: ", 101)); + newContact.SetEmail(PromptCharInput("What is your email?: ", 101)); + newContact.SetState(PromptCharInput("What is your state?: ", 101)); + newContact.SetCity(PromptCharInput("What is your city?: ", 101)); + newContact.SetZip(InputInt("What is your zip?")); + + + return newContact; + + + +} + +void PrintContact(ContactList<Contact>& contacts) +{ + contacts.PrintList(); +} + + + +Contact NewContact() +{ + Contact newContact; + + return newContact; +} + + + +char* PromptCharInput(const char* prompt, long long maxlen) +{ + std::cout.flush(); + std::cout << prompt << std::endl; + + char* input = new char[maxlen]; + + do + { + std::cin.clear(); + cin.get(input, maxlen, '\n'); + cin.ignore(MAX_STREAM_SIZE, '\n'); + + } while (!std::cin); + + return input; + +} +int InputInt(const char* prompt) +{ + std::cout << prompt << std::endl; + + std::cout.flush(); + + int data = 0; + std::cin >> data; + + while (!std::cin) + { + std::cout << prompt << std::endl; + std::cin.clear(); + + cin.ignore(MAX_STREAM_SIZE, '\n'); + std::cin >> data; + + } + + return data; +} + + + + + + + + + + + + +#endif
\ No newline at end of file |