Exemplo n.º 1
0
 @Override
 public boolean registerBid(double value, int uniqueUserId, int auctionId) throws RemoteException {
   RMIClientIntf clientIntf = registeredUsers.get(uniqueUserId);
   Bid bid = new Bid(value, uniqueUserId);
   if (!liveAuctionItems.containsKey(auctionId)) {
     clientIntf.callBack("Auction item id does not exist\n");
     return false;
   }
   if (uniqueUserId == liveAuctionItems.get(auctionId).getCreator_id()) {
     clientIntf.callBack("Not able to register bid - bidder is the creator of this auction\n");
     return false;
   } else {
     if (liveAuctionItems.get(auctionId).addBidder(bid)) {
       clientIntf.callBack(
           "Bid registered to auction with id "
               + auctionId
               + " and amount "
               + bid.getBid()
               + "\n");
       return true;
     } else {
       clientIntf.callBack(
           "Bid rejected, user has already placed a bid for this auction, can only place higher bids\n");
       return false;
     }
   }
 }