#include "BuyOrder.h" #include "Investor.h" BuyOrder::BuyOrder( Investor* i , Stock* s, double price, long amount ) : Order( i, s, price, amount ) { if ( i != 0 ) i->reserve( cost() ); } BuyOrder::~BuyOrder() { investor_->release( price() * amount() ); } bool BuyOrder::execute( double price, long amount ) { assert( amount <= Order::amount() ); bool ret = true; if ( investor_ != 0 ) { investor_->buy( stock(), price, amount ); investor_->release( Order::price() * amount ); } dump( price, amount ); return ret; }