-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMenus.cpp
52 lines (44 loc) · 1.32 KB
/
Menus.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#pragma once
#include <vector>
#include <iostream>
#include "CinCleanup.cpp"
namespace MenuItems
{
const std::vector mainMenu{"Ask a question",
"Read the I Ching",
"Find a quote",
"See the Hexagrams",
"See the Hexagram cross reference",
"Recall past questions",
"Print a random quote",
"Exit"};
};
// Prints the main menu
void printMainMenu()
{
std::cout << "MAIN MENU\n";
for (size_t i = 0; i < MenuItems::mainMenu.size(); i++)
std::cout << i << ") " << MenuItems::mainMenu[i] << '\n';
}
// User input for the main menu
int selectFromMainMenu()
{
int choise;
while (true)
{
std::cout << "Choose what you want to do[0-" << MenuItems::mainMenu.size() - 1 << "]: ";
std::cin >> choise;
if (clearFailedExtraction() || clearExtraInput())
{
std::cout << "Wrong input. Try again!\n";
continue;
}
if (!(choise >= 0 && choise < static_cast<int>(MenuItems::mainMenu.size())))
{
std::cout << "Wrong input. Try again!\n";
continue;
}
break;
}
return choise;
}