Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Lot
- {
- private final int Id;
- private String lotname;
- private Bid highestBid;
- //Menyimpan jumlah dan nama barang yang akan dilelang
- public Lot(int number, String lotname)
- {
- this.Id = number;
- this.lotname = lotname;
- }
- //Mengecek apakah harga baru melebihi highest bid atau tidak
- public boolean bidFor(Bid bid)
- {
- if((highestBid == null) ||
- (bid.getBid() > highestBid.getBid())) {
- highestBid = bid;
- return true;
- }
- else {
- return false;
- }
- }
- //Menampilkan apakah barang sudah terlelang atau belum
- public String detail()
- {
- String details = Id + ": " + lotname;
- if(highestBid != null) {
- details += " Bid with price " +
- highestBid.getBid();
- }
- else {
- details += " (no bid yet)";
- }
- return details;
- }
- public int getId()
- {
- return Id;
- }
- public String getLotName()
- {
- return lotname;
- }
- public Bid getHighestBid()
- {
- return highestBid;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment