Examples of AuctionDetail


Examples of edu.csusm.cs671.auction.model.AuctionDetail

    }
  }

  @Override
  public void addTask(Work w) {
    AuctionDetail auctionDetail = new AuctionDetail(w.getWorkType(), w.getSize());
    auctionQueue.add(auctionDetail);
    startAuction();
  }
View Full Code Here

Examples of edu.csusm.cs671.auction.model.AuctionDetail

    while(!auctionQueue.isEmpty())
    {
      if(isRunning)
      {
        StartAuctionMessage msg = new StartAuctionMessage();
        AuctionDetail auctionDetail = auctionQueue.poll();
       
        if(auctionDetail == null){
          continue;
        }
       
        msg.setWorkForAuction(auctionDetail.getWorkDetail());
        msg.setAuctionID(auctionDetail.getID());
        bidderList.clear();
        listenning = true;
        server.writeToAll(msg);

        int delay = 1000;
        try {
          Thread.sleep(delay);
        } catch (InterruptedException e1) {
        }
        //decide who win
        BidAuctionMessage highestBidder;
        highestBidder = getHighestBidder();
        if(highestBidder == null)
        {
          listenning = false;
          continue;
        }
        //        while((highestBidder = getHighestBidder())==null)
        //        {
        //          server.writeToAll(msg);
        //        }

        try{
          System.out.println("Winner:Agent_"+highestBidder.getAgentID() + " AuctionID = " + msg.getAuctionID());
          System.out.println("   Work size: "+ msg.getWorkForAuction().getSize().getValue() + "  Work type: " + msg.getWorkForAuction().getWorkType());
          WinnerAuctionMessage winnerAuctionMessage = new WinnerAuctionMessage();
          winnerAuctionMessage.setAgentID(highestBidder.getAgentID());
          winnerAuctionMessage.setBidAmount(highestBidder.getBidAmount());
          winnerAuctionMessage.setWorkForAuction(msg.getWorkForAuction());
          server.writeToAgent(winnerAuctionMessage, highestBidder.getAgentID());

          //update history
          auctionDetail.setWinner("agent_"+highestBidder.getAgentID());
          auctionDetail.setWinningPrice(highestBidder.getBidAmount());
          auctionHistory.add(auctionDetail);

        }
        catch(Exception e)
        {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.