document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. import java.util.*;
  2. import javax.swing.*;
  3.  
  4. public class Lot  
  5.  {    
  6.    private final int number;    
  7.    private String description;    
  8.    private Bid highestBid;  
  9.  
  10.    public Lot (int number, String description)  
  11.    {  
  12.      this.number = number;  
  13.      this.description = description;  
  14.      this.highestBid = null;  
  15.    }  
  16.    /**  
  17.     * Attempt to bid for this lot.  
  18.     * A succesful bid must have a value higher than any existing bid.  
  19.     * @param bid A new bid  
  20.     * @return true if succesful. false otherwise  
  21.     */  
  22.    public boolean bidFor(Bid bid)  
  23.    {  
  24.      if (highestBid==null)  
  25.      {  
  26.        highestBid=bid;  
  27.        return true;  
  28.      }  
  29.      else if (bid.getValue() > highestBid.getValue())  
  30.      {    
  31.        highestBid = bid;  
  32.        return true;  
  33.      }  
  34.      else  
  35.      {  
  36.        return false;  
  37.      }  
  38.    }  
  39.    /**  
  40.     * @return A string representation of this lot\'s details.  
  41.     */  
  42.    public String toString()  
  43.    {  
  44.      String details = number + ": " + description;  
  45.      if (highestBid != null)  
  46.      {  
  47.        details += " Bid: " + highestBid.getValue();  
  48.      }  
  49.      else  
  50.      {  
  51.        details += " (No bid))";  
  52.      }  
  53.      return details;  
  54.    }  
  55.    /**  
  56.     * @return The lot\'s number.  
  57.     */  
  58.    public int getNumber()  
  59.    {  
  60.      return number;  
  61.    }  
  62.    /**  
  63.     * @return The lot\'s description.  
  64.     */  
  65.    public String getDescription()  
  66.    {  
  67.      return description;  
  68.    }  
  69.    /**  
  70.     * @return The highest bid for this lot.  
  71.     *  This could be null if there is no current bid.  
  72.     */  
  73.    public Bid getHighestBid()  
  74.    {  
  75.      return highestBid;  
  76.    }  
  77. }
');