📄 item.java
字号:
/*
* Created on 2005-9-4
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package com.bid.domain;
import java.io.Serializable;
import java.util.Date;
import java.util.Set;
import java.math.BigDecimal;
import com.bid.exceptions.*;
/**
* @author Ma Dou
*
* TODO To change the template for this generated type comment go to Window -
* Preferences - Java - Code Style - Code Templates
*/
public class Item implements Serializable {
private long id;
private Date endDate;
private String itemName;
/**
* @return Returns the itemName.
*/
public String getItemName() {
return itemName;
}
/**
* @param itemName The itemName to set.
*/
public void setItemName(String itemName) {
this.itemName = itemName;
}
private Set bids;
/**
*
*/
public Item() {
super();
}
/**
* @return Returns the bids.
*/
public Set getBids() {
return bids;
}
/**
* @param bids
* The bids to set.
*/
public void setBids(Set bids) {
this.bids = bids;
}
/**
* @return Returns the endDate.
*/
public Date getEndDate() {
return endDate;
}
/**
* @param endDate
* The endDate to set.
*/
public void setEndDate(Date endDate) {
this.endDate = endDate;
}
/**
* @return Returns the id.
*/
public long getId() {
return id;
}
/**
* @param id
* The id to set.
*/
public void setId(long id) {
this.id = id;
}
public Bid placeBid(User bidder, BigDecimal bidAmount,BigDecimal maxAmount)
throws BusinessException {
// Auction still valid
if (this.getEndDate().before(new Date())) {
throw new BusinessException("Auction.already.ended.");
}
// Auction still valid
if (!(bidAmount.compareTo(maxAmount)>0)) {
throw new BusinessException("Bidamount.lower.than.current");
}
// Create new Bid
Bid newBid = new Bid(bidAmount, this, bidder);
// Place bid for this Item
this.addBid(newBid);
return newBid;
}
private void addBid(Bid bid) {
this.bids.add(bid);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -