Advertisement
raffi_pratama

Untitled

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