document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. import java.util.*;
  2. import javax.swing.*;
  3. /**
  4.  * Write a description of class Lot here.
  5.  * Untuk menentukan jumlah bid dihitung untuk bisa berulang kali bid sebuah
  6.  * barang lelang
  7.  * @author Fitrah Arie Ramadhan
  8.  * @version Final Version, 21 Oktober 2020
  9.  */
  10. public class Lot
  11. {
  12.     private final int codeB;
  13.     private String nameB;
  14.     private Bid HighestBid;
  15.     public Lot(int codeB, String nameB){
  16.         this.codeB = codeB;
  17.         this.nameB= nameB;
  18.         this.HighestBid= null;
  19.     }
  20.     public boolean bidFor(Bid bid){
  21.         if(HighestBid == null){
  22.             HighestBid= bid;
  23.             return true;
  24.         }
  25.         //jika harga lebih besar dari harga sebelumnya maka di passing
  26.         else if(bid.getValue() > HighestBid.getValue()){
  27.             HighestBid= bid;
  28.             return true;
  29.         }
  30.         else{
  31.             return false;
  32.         }
  33.     }
  34.     public String toString(){
  35.         String details= codeB + ": " +nameB;
  36.         if(HighestBid != null){
  37.             details += "Tawaran: " + HighestBid.getValue();
  38.         }
  39.         else{
  40.             details += "(Tidak ada Tawaran)";
  41.         }
  42.         return details;
  43.     }
  44.     public int getCode()
  45.     {
  46.         return codeB;
  47.     }
  48.     public String getName(){
  49.         return nameB;
  50.     }
  51.     public Bid getHighest(){
  52.         return HighestBid;
  53.     }
  54.    
  55. }
  56.  
');