We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d4fc6e0 commit 681f9f0Copy full SHA for 681f9f0
shm/Game.cpp
@@ -72,7 +72,7 @@ void Game::travel()
72
printMap(*map_);
73
std::cout << "Choose Your destination captain!" << '\n';
74
std::cin >> i;
75
- if (i < map_->islands_.size() && i >= 0)
+ if (isdigit(i) && i < map_->islands_.size() && i >= 0)
76
{
77
auto travelTime = map_->calculateDistance(map_->islands_.at(i)) / playerOne_->getSpeed();
78
std::cout << "Your travel will take " << travelTime << " days." << '\n';
@@ -84,6 +84,8 @@ void Game::travel()
84
else
85
86
std::cout << "There is no such island on the map! Choose another destination!" << '\n';
87
+ std::cin.clear();
88
+ std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
89
Game::travel();
90
}
91
0 commit comments