diff --git a/CM2005 Object Oriented Programming/Topic 4/4.4.7/MerkelMain.cpp b/CM2005 Object Oriented Programming/Topic 4/4.4.7/MerkelMain.cpp index e82d2be..a611a2f 100644 --- a/CM2005 Object Oriented Programming/Topic 4/4.4.7/MerkelMain.cpp +++ b/CM2005 Object Oriented Programming/Topic 4/4.4.7/MerkelMain.cpp @@ -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::max(), '\n'); + //std::cin.ignore(std::numeric_limits::max(), '\n'); std::getline(std::cin, input); + std::vector 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; } diff --git a/CM2005 Object Oriented Programming/Topic 4/4.4.7/a.exe b/CM2005 Object Oriented Programming/Topic 4/4.4.7/a.exe index 2bf5f1c..2d318a1 100644 Binary files a/CM2005 Object Oriented Programming/Topic 4/4.4.7/a.exe and b/CM2005 Object Oriented Programming/Topic 4/4.4.7/a.exe differ