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 {
2222 Exit
2323 };
2424
25+ enum class ConfirmOption {
26+ Yes,
27+ No,
28+ Error
29+ };
30+
2531 void startGame ();
2632
2733private:
@@ -48,6 +54,7 @@ class Game {
4854 bool isGameWon () const ;
4955 bool isGameLost () const ;
5056 bool validatingMenuChoose (size_t option);
57+ ConfirmOption confirmOption (std::string announcement);
5158
5259 MenuOption menuOption_ { MenuOption::NoChoose };
5360};
Original file line number Diff line number Diff line change @@ -121,6 +121,20 @@ bool Game::validatingMenuChoose(size_t option) {
121121 return true ;
122122}
123123
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+
124138void Game::travel () {
125139
126140}
You can’t perform that action at this time.
0 commit comments