Update changed user input method on main menu

This commit is contained in:
Lev
2021-06-11 14:23:35 -05:00
parent 3932996f5d
commit 463a50b106
2 changed files with 14 additions and 3 deletions

View File

@ -75,8 +75,9 @@ void MerkelMain::enterAsk()
{
std::cout << "Make an ask - enter the amount (product, price, amount. e.g. 'ETH/BTC, 200, 0.5)': " << std::endl;
std::string input;
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
//std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
std::getline(std::cin, input);
std::vector<std::string> tokens = CSVReader::tokenise(input, ',');
if(tokens.size() != 3)
{
@ -114,10 +115,20 @@ void MerkelMain::gotoNextTimeframe()
int MerkelMain::getUserOption()
{
int userOption;
int userOption = 0;
std::string line;
std::cout << "Type in 1-6" << std::endl;
std::cin >> userOption;
std::getline(std::cin, line);
//std::cin >> userOption;
try
{
userOption = std::stoi(line);
}
catch(const std::exception& e)
{
std::cout << "Invalid input!" << std::endl;
}
std::cout << "You chose: " << userOption << std::endl;
return userOption;
}