diff options
| author | rPatrickWarner <[email protected]> | 2024-03-09 13:30:44 -0800 |
|---|---|---|
| committer | rPatrickWarner <[email protected]> | 2024-03-09 13:30:44 -0800 |
| commit | 61d278d69bba29cce0fec8dc0a75c528b1b95b71 (patch) | |
| tree | 41ab75825e25885a5bb978db8bcfb3954e9b62fa /Homework8/MyStructures/MenuHelper.hpp | |
| parent | more changes/coming along (diff) | |
| download | homework-8-reecepwarner-61d278d69bba29cce0fec8dc0a75c528b1b95b71.tar.xz homework-8-reecepwarner-61d278d69bba29cce0fec8dc0a75c528b1b95b71.zip | |
some changes
Diffstat (limited to 'Homework8/MyStructures/MenuHelper.hpp')
| -rw-r--r-- | Homework8/MyStructures/MenuHelper.hpp | 176 |
1 files changed, 90 insertions, 86 deletions
diff --git a/Homework8/MyStructures/MenuHelper.hpp b/Homework8/MyStructures/MenuHelper.hpp index f13656e..bb5a70d 100644 --- a/Homework8/MyStructures/MenuHelper.hpp +++ b/Homework8/MyStructures/MenuHelper.hpp @@ -4,64 +4,63 @@ #define _CRT_SECURE_NO_WARNINGS #include "ContactList.hpp" -using namespace MyStructures; +namespace MyStructures +{ + void MainMenu(); + Contact InputContact(); -void MainMenu(); + char* PromptCharInput(const char* prompt, long long maxlen); -Contact InputContact(); + int InputInt(const char* prompt); -char* PromptCharInput(const char* prompt, long long maxlen); + void PrintContact(ContactList<Contact>& contacts); -int InputInt(const char* prompt); + Contact NewContact(); -void PrintContact(ContactList<Contact>& contacts); + void PrintContact(ContactList<Contact>& contacts); -Contact NewContact(); + bool OverWriteCharArray(); -void PrintContact(ContactList<Contact>& contacts); + void MainMenu() + { + char Options = '\0'; -bool OverWriteCharArray(); -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'); + } - do + Contact InputContact() { - 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)); @@ -77,69 +76,74 @@ Contact InputContact() -} + } -void PrintContact(ContactList<Contact>& contacts) -{ - contacts.PrintList(); -} + void PrintContact(ContactList<Contact>& contacts) + { + contacts.PrintList(); + } -inline bool OverWriteCharArray() -{ - return false; -} + inline bool OverWriteCharArray() + { + return false; + } -Contact NewContact() -{ - Contact newContact; + Contact NewContact() + { + Contact newContact; - return newContact; -} + return newContact; + } -char* PromptCharInput(const char* prompt, long long maxlen) -{ - std::cout.flush(); - std::cout << prompt << std::endl; - - char* input = new char[maxlen]; - cin >> input; - while (!std::cin) + char* PromptCharInput(const char* prompt, long long maxlen) { - cout << prompt << std::endl; - cin.clear(); - - cin.ignore(MAX_STREAM_SIZE, '\n'); - cin.get(input, MAX_STREAM_SIZE, '\n'); - } - - return input; + std::cout.flush(); + std::cout << prompt << std::endl; -} -int InputInt(const char* prompt) -{ - std::cout << prompt << std::endl; + char* input = new char[maxlen]; + cin >> input; + while (!std::cin) + { + cout << prompt << std::endl; + cin.clear(); - std::cout.flush(); + cin.ignore(MAX_STREAM_SIZE, '\n'); + cin.get(input, MAX_STREAM_SIZE, '\n'); + } - int data = 0; - std::cin >> data; + return input; - while (!std::cin) + } + int InputInt(const char* prompt) { std::cout << prompt << std::endl; - std::cin.clear(); - cin.ignore(MAX_STREAM_SIZE, '\n'); + 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; } - return data; -} + + + +}; |