Advertisement
lamaulfarid

Lot

Oct 29th, 2020
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.42 KB | None | 0 0
  1.  
  2. /**
  3.  * Write a description of class Lot here.
  4.  *
  5.  * @author Ahmad Lamaul Farid
  6.  * @version 28 Oktober 2020
  7.  */
  8.  
  9. public class Lot
  10. {
  11.     private final int ID;  
  12.     private String ItemName;  
  13.     private Bid highestBid;
  14.    
  15.     // menyimpan jumlah dan nama barang yang akan dilelang
  16.     public Lot(int number, String lotname)
  17.     {
  18.         this.ID = number;
  19.         this.ItemName = lotname;
  20.         this.highestBid = null;
  21.     }
  22.    
  23.     // untuk mengecek apakah harga baru melebihi highest bid atau tidak
  24.     public boolean bidFor(Bid bid)  
  25.     {  
  26.         if((highestBid == null) || (bid.getBid() > highestBid.getBid()))
  27.         {  
  28.             highestBid = bid;
  29.             return true;
  30.         }  
  31.         else
  32.         {  
  33.             return false;  
  34.         }
  35.     }
  36.    
  37.     // untuk menampilkan apakah barang sudah terlelang atau belum
  38.     public String detail()  
  39.     {  
  40.        String details = ID + ": " + ItemName;
  41.        if(highestBid != null)
  42.        {  
  43.            details += " Bid : " +    
  44.            highestBid.getBid();
  45.         }  
  46.        else
  47.        {  
  48.            details += " (No bid yet)";  
  49.        }  
  50.        return details;  
  51.     }
  52.    
  53.     public int getID()  
  54.     {  
  55.         return ID;  
  56.     }  
  57.    
  58.     public String getLotName()  
  59.     {  
  60.         return ItemName;  
  61.     }  
  62.    
  63.     public Bid getHighestBid()  
  64.     {      
  65.         return highestBid;  
  66.     }  
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement