/** * Called by a buyer that wants to buy directly from this agent, not going through the market. * * @param buyerQuote the quote (including the offer price) of the buyer * @param sellerQuote the quote (including the offer price) of the seller; I expect the buyer to * have achieved this through asked for an offer function * @return a purchaseResult including whether the trade was succesful and if so the final price */ @Override public PurchaseResult shopHere(Quote buyerQuote, Quote sellerQuote) { int finalPrice = market.price(sellerQuote.getPriceQuoted(), buyerQuote.getPriceQuoted()); assert sellerQuote.getGood() != null; assert this.has(sellerQuote.getGood()); // exchange hostages market.trade( buyerQuote.getAgent(), this, sellerQuote.getGood(), finalPrice, buyerQuote, sellerQuote); this.logEvent( this, MarketEvents.SOLD, this.getModel().getCurrentSimulationTimeInMillis(), "price: " + finalPrice + ", through buyFromHere()"); // sold a good assert !this.has(sellerQuote.getGood()); PurchaseResult toReturn = PurchaseResult.SUCCESS; toReturn.setPriceTrade(finalPrice); return toReturn; }