Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Write a description of class Lot here.
- *
- * @author Ahmad Lamaul Farid
- * @version 28 Oktober 2020
- */
- public class Lot
- {
- private final int ID;
- private String ItemName;
- private Bid highestBid;
- // menyimpan jumlah dan nama barang yang akan dilelang
- public Lot(int number, String lotname)
- {
- this.ID = number;
- this.ItemName = lotname;
- this.highestBid = null;
- }
- // untuk mengecek apakah harga baru melebihi highest bid atau tidak
- public boolean bidFor(Bid bid)
- {
- if((highestBid == null) || (bid.getBid() > highestBid.getBid()))
- {
- highestBid = bid;
- return true;
- }
- else
- {
- return false;
- }
- }
- // untuk menampilkan apakah barang sudah terlelang atau belum
- public String detail()
- {
- String details = ID + ": " + ItemName;
- if(highestBid != null)
- {
- details += " Bid : " +
- highestBid.getBid();
- }
- else
- {
- details += " (No bid yet)";
- }
- return details;
- }
- public int getID()
- {
- return ID;
- }
- public String getLotName()
- {
- return ItemName;
- }
- public Bid getHighestBid()
- {
- return highestBid;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement