import java.util.*;
import javax.swing.*;
/**
* Write a description of class Lot here.
* Kelas untuk memasukkan deskripsibarang dan menentukan bid yang
* dihitung untuk bisa berulang kali bid barang yang dilelang
* @author Raharja Dui Putra Sutedjo
* @version 25 Oktober 2020
*/
public class Lot
{
private final int number;
private String description;
private Bid highestBid;
/**
* Construct a Lot, setting its number and description.
* @param number The lot number.
* @param description A description of this lot.
*/
public Lot (int number, String description)
{
this.number = number;
this.description = description;
this.highestBid = null;
}
/**
* Attempt to bid for this lot.
* A succesful bid must have a value higher than any existing bid.
* @param bid A new bid
* @return true if succesful. false otherwise
*/
public boolean bidFor(Bid bid)
{
if (highestBid==null)
{
highestBid=bid;
return true;
}
else if (bid.getValue() > highestBid.getValue())
{
highestBid = bid;
return true;
}
else
{
return false;
}
}
/**
* @return A string representation of this lot\'s details.
*/
public String toString()
{
String details = number + ": " + description;
if (highestBid != null)
{
details += " Bid: " + highestBid.getValue();
}
else
{
details += " (No bid))";
}
return details;
}
/**
* @return The lot\'s number.
*/
public int getNumber()
{
return number;
}
/**
* @return The lot\'s description.
*/
public String getDescription()
{
return description;
}
/**
* @return The highest bid for this lot.
* This could be null if there is no current bid.
*/
public Bid getHighestBid()
{
return highestBid;
}
}