diff --git a/CM2005 Object Oriented Programming/Topic 5/5.1.15/MerkelMain.cpp b/CM2005 Object Oriented Programming/Topic 5/5.1.15/MerkelMain.cpp index 4aea43a..a67711c 100644 --- a/CM2005 Object Oriented Programming/Topic 5/5.1.15/MerkelMain.cpp +++ b/CM2005 Object Oriented Programming/Topic 5/5.1.15/MerkelMain.cpp @@ -104,7 +104,41 @@ void MerkelMain::enterAsk() void MerkelMain::enterBid() { - std::cout << "Make a bid - enter the amount" << std::endl; + std::cout << "Make a bid - enter the amount: product,price, amount, eg ETH/BTC,200,0.5" << std::endl; + std::string input; + std::getline(std::cin, input); + + std::vector tokens = CSVReader::tokenise(input, ','); + if (tokens.size() != 3) + { + std::cout << "MerkelMain::enterBid Bad input! " << input << std::endl; + } + else { + try { + OrderBookEntry obe = CSVReader::stringsToOBE( + tokens[1], + tokens[2], + currentTime, + tokens[0], + OrderBookType::bid + ); + if(wallet.canFulfillOrder(obe)) + { + std::cout << "Wallet looks good. " << std::endl; + orderBook.insertOrder(obe); + } + else + { + std::cout << "Wallet has insufficient asks" << std::endl; + } + + }catch (const std::exception& e) + { + std::cout << " MerkelMain::enterBid Bad input " << std::endl; + } + } + + std::cout << "You typed: " << input << std::endl; } void MerkelMain::printWallet() diff --git a/CM2005 Object Oriented Programming/Topic 5/5.1.15/a.exe b/CM2005 Object Oriented Programming/Topic 5/5.1.15/a.exe index 9eaaaf5..9e4f4a3 100644 Binary files a/CM2005 Object Oriented Programming/Topic 5/5.1.15/a.exe and b/CM2005 Object Oriented Programming/Topic 5/5.1.15/a.exe differ