Daffa404

Untitled

Oct 27th, 2020
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.22 KB | None | 0 0
  1. public class Lot
  2. {
  3.     private final int Id;  
  4.     private String lotname;  
  5.     private Bid highestBid;
  6.     //Menyimpan jumlah dan nama barang yang akan dilelang
  7.     public Lot(int number, String lotname)
  8.     {
  9.         this.Id = number;
  10.         this.lotname = lotname;
  11.     }
  12.     //Mengecek apakah harga baru melebihi highest bid atau tidak
  13.     public boolean bidFor(Bid bid)  
  14.     {  
  15.         if((highestBid == null) ||  
  16.         (bid.getBid() > highestBid.getBid())) {  
  17.             highestBid = bid;
  18.             return true;
  19.         }  
  20.         else {  
  21.             return false;  
  22.         }
  23.     }
  24.     //Menampilkan apakah barang sudah terlelang atau belum
  25.     public String detail()  
  26.     {  
  27.        String details = Id + ": " + lotname;
  28.        if(highestBid != null) {  
  29.            details += " Bid with price " +    
  30.            highestBid.getBid();
  31.         }  
  32.         else {  
  33.             details += " (no bid yet)";  
  34.         }  
  35.        return details;  
  36.     }
  37.    
  38.     public int getId()  
  39.     {  
  40.         return Id;  
  41.     }  
  42.    
  43.     public String getLotName()  
  44.     {  
  45.         return lotname;  
  46.     }  
  47.    
  48.     public Bid getHighestBid()  
  49.     {      
  50.         return highestBid;  
  51.     }  
  52. }
Advertisement
Add Comment
Please, Sign In to add comment