diff --git a/CM2005 Object Oriented Programming/Topic 5/5.3.3/MerkelMain.cpp b/CM2005 Object Oriented Programming/Topic 5/5.3.3/MerkelMain.cpp index eeb3b3d..c024c54 100644 --- a/CM2005 Object Oriented Programming/Topic 5/5.3.3/MerkelMain.cpp +++ b/CM2005 Object Oriented Programming/Topic 5/5.3.3/MerkelMain.cpp @@ -81,8 +81,9 @@ void MerkelMain::enterAsk() tokens[2], currentTime, tokens[0], - OrderBookType::ask + OrderBookType::ask ); + obe.username = "simuser"; if(wallet.canFulfillOrder(obe)) { std::cout << "Wallet looks good. " << std::endl; @@ -122,6 +123,7 @@ void MerkelMain::enterBid() tokens[0], OrderBookType::bid ); + obe.username = "simuser"; if(wallet.canFulfillOrder(obe)) { std::cout << "Wallet looks good. " << std::endl; diff --git a/CM2005 Object Oriented Programming/Topic 5/5.3.3/OrderBook.cpp b/CM2005 Object Oriented Programming/Topic 5/5.3.3/OrderBook.cpp index 321962a..9102b77 100644 --- a/CM2005 Object Oriented Programming/Topic 5/5.3.3/OrderBook.cpp +++ b/CM2005 Object Oriented Programming/Topic 5/5.3.3/OrderBook.cpp @@ -134,9 +134,20 @@ std::vector OrderBook::matchAsksToBids(std::string product, std: if (bid.price >= ask.price) { std::cout << "bid price is right " << std::endl; - // sale = new order() - // sale.price = ask.price - OrderBookEntry sale{ask.price, 0, timestamp, product, OrderBookType::sale}; + OrderBookEntry sale{ask.price, 0, timestamp, product, OrderBookType::asksale}; + OrderBookType type = OrderBookType::asksale; + if(bid.username == "simuser") + { + sale.username = "simuser"; + sale.orderType = OrderBookType::bidsale; + } + if(ask.username == "simuser") + { + + sale.username = "simuser"; + sale.orderType = OrderBookType::asksale; + } + // # now work out how much was sold and // # create new bids and asks covering // # anything that was not sold diff --git a/CM2005 Object Oriented Programming/Topic 5/5.3.3/OrderBookEntry.cpp b/CM2005 Object Oriented Programming/Topic 5/5.3.3/OrderBookEntry.cpp index 871266a..b4de0c7 100644 --- a/CM2005 Object Oriented Programming/Topic 5/5.3.3/OrderBookEntry.cpp +++ b/CM2005 Object Oriented Programming/Topic 5/5.3.3/OrderBookEntry.cpp @@ -4,12 +4,14 @@ OrderBookEntry::OrderBookEntry( double _price, double _amount, std::string _timestamp, std::string _product, - OrderBookType _orderType) + OrderBookType _orderType, + std::string _username) : price(_price), amount(_amount), timestamp(_timestamp), product(_product), - orderType(_orderType) + orderType(_orderType), + username(_username) { } diff --git a/CM2005 Object Oriented Programming/Topic 5/5.3.3/OrderBookEntry.h b/CM2005 Object Oriented Programming/Topic 5/5.3.3/OrderBookEntry.h index c5204bc..a490c7c 100644 --- a/CM2005 Object Oriented Programming/Topic 5/5.3.3/OrderBookEntry.h +++ b/CM2005 Object Oriented Programming/Topic 5/5.3.3/OrderBookEntry.h @@ -2,7 +2,7 @@ #include -enum class OrderBookType{bid, ask, unknown, sale}; +enum class OrderBookType{bid, ask, unknown, asksale, bidsale}; class OrderBookEntry { @@ -12,7 +12,8 @@ class OrderBookEntry double _amount, std::string _timestamp, std::string _product, - OrderBookType _orderType); + OrderBookType _orderType, + std::string username = "dataset"); static OrderBookType stringToOrderBookType(std::string s); @@ -34,4 +35,5 @@ class OrderBookEntry std::string timestamp; std::string product; OrderBookType orderType; + std::string username; };