File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,12 @@ class Game {
22
22
Exit
23
23
};
24
24
25
+ enum class ConfirmOption {
26
+ Yes,
27
+ No,
28
+ Error
29
+ };
30
+
25
31
void startGame ();
26
32
27
33
private:
@@ -48,6 +54,7 @@ class Game {
48
54
bool isGameWon () const ;
49
55
bool isGameLost () const ;
50
56
bool validatingMenuChoose (size_t option);
57
+ ConfirmOption confirmOption (std::string announcement);
51
58
52
59
MenuOption menuOption_ { MenuOption::NoChoose };
53
60
};
Original file line number Diff line number Diff line change @@ -121,6 +121,20 @@ bool Game::validatingMenuChoose(size_t option) {
121
121
return true ;
122
122
}
123
123
124
+ Game::ConfirmOption Game::confirmOption (std::string announcemen) {
125
+ std::cout << announcemen << ' \n ' ;
126
+ char answer;
127
+ std::cin >> answer;
128
+ if (answer == ' Y' || answer == ' y' ) {
129
+ return ConfirmOption::Yes;
130
+ }
131
+ if (answer == ' N' || answer == ' n' ) {
132
+ return ConfirmOption::No;
133
+ }
134
+ std::cout << " Wrong answer, you must choose Y or N\n " ;
135
+ return ConfirmOption::Error;
136
+ }
137
+
124
138
void Game::travel () {
125
139
126
140
}
You can’t perform that action at this time.
0 commit comments