Advertisement
kuchuz

PBO-C 4 : Lot()

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