trizehn

Lot

Nov 4th, 2020
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.19 KB | None | 0 0
  1.  
  2. /**
  3.  * Write a description of class Lot here.
  4.  *
  5.  * @author Daffa Tristan Firdaus
  6.  * @version 4 November 2020
  7.  */
  8. public class Lot
  9. {
  10.     private final int ID;  
  11.     private String ItemName;  
  12.     private Bid highestBid;
  13.     public Lot(int number, String lotname)
  14.     {
  15.         this.ID = number;
  16.         this.ItemName = lotname;
  17.         this.highestBid = null;
  18.     }
  19.     public boolean bidFor(Bid bid)  
  20.     {
  21.         if((highestBid == null) || (bid.getBid() > highestBid.getBid()))
  22.         {  
  23.             highestBid = bid;
  24.             return true;
  25.         }  
  26.         else
  27.         {  
  28.             return false;  
  29.         }
  30.     }
  31.     public String detail()  
  32.     {
  33.         String details = ID + ": " + ItemName;
  34.         if(highestBid != null)
  35.         {  
  36.            details += " Bid : " +    
  37.            highestBid.getBid();
  38.         }
  39.         else
  40.         {  
  41.            details += " (No bid yet)";
  42.         }
  43.         return details;  
  44.     }
  45.     public int getID()  
  46.     {  
  47.         return ID;  
  48.     }  
  49.     public String getLotName()  
  50.     {  
  51.         return ItemName;  
  52.     }
  53.     public Bid getHighestBid()  
  54.     {      
  55.         return highestBid;  
  56.     }  
  57. }
Advertisement
Add Comment
Please, Sign In to add comment