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