From 92e69846f794234629a072c8d0766c2e0a2ea77c Mon Sep 17 00:00:00 2001 From: Matti Date: Fri, 22 Nov 2024 14:52:07 +0100 Subject: [PATCH] Add Menu Manager --- Aufg8/MenuManager.cpp | 32 ++++++++++++++++++ Aufg8/MenuManager.h | 79 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+) create mode 100644 Aufg8/MenuManager.cpp create mode 100644 Aufg8/MenuManager.h diff --git a/Aufg8/MenuManager.cpp b/Aufg8/MenuManager.cpp new file mode 100644 index 0000000..8e769c8 --- /dev/null +++ b/Aufg8/MenuManager.cpp @@ -0,0 +1,32 @@ +#include +#include + +class MenuManager { + // public: + // MenuManager(); + // int AcceptIntInputInRange(int minInput, int maxInput) { + // int input; + // std::cin >> input; + // + // while (input < minInput || input > maxInput) { + // std::cout << "Enter a number between " << minInput << " and " << maxInput << ": "; + // std::cin >> input; + // } + // return input; + // } + // + // int ShowMainMenu() { + // system("cls"); + // + // std::cout<<"Select Information to display" < + +class MenuManager { + private: + int* currentMenu; + std::string* selectedMetric; + std::string* selectedRegion; + public: + MenuManager(int* currentMenu, std::string* selectedMetric, std::string* selectedRegion){ + this->currentMenu = currentMenu; + this->selectedRegion = selectedRegion; + this->selectedMetric = selectedMetric; + } + int AcceptIntInputInRange(int minInput, int maxInput) { + int input; + std::cin >> input; + + while (input < minInput || input > maxInput) { + std::cout << "Enter a number between " << minInput << " and " << maxInput << ": "; + std::cin >> input; + } + return input; + } + + int ShowMainMenu() { + // system("cls"); + + std::cout<<"Select Information to display" <> prompt; + return prompt; + } + + void MainInteraction() { + *currentMenu = ShowMainMenu(); + switch (*currentMenu) { + case 0: + return; + case 1: + *selectedMetric = ShowPromptAndGetString("Enter The Metric to get total Profit for"); break; + case 2: + *selectedMetric = ShowPromptAndGetString("Enter The item type to search for"); + *selectedRegion = ShowPromptAndGetString("Enter The region to search in"); + break; + case 3: + *selectedMetric = ShowPromptAndGetString("Enter The country to get most common type for"); + break; + case 4: + *selectedRegion = ShowPromptAndGetString("Select Country to count online vs offline purchases"); + break; + default: + std::cout << "You should not be able to reach this point if you entered a legal number"; + } + + } +}; + + +#endif //MENUMANAGER_H