?? cartitem.java
字號:
package com.jspdev.cart;
import java.io.*;
import java.math.*;
import com.jspdev.vo.*;
/**
*代表了購物車中各個item的信息
*/
public class CartItem implements Serializable {
/* Private Fields */
private Item item;
private int quantity;
private boolean inStock;
private BigDecimal total;
/* JavaBeans Properties */
public boolean isInStock() { return inStock; }
public void setInStock(boolean inStock) { this.inStock = inStock; }
public BigDecimal getTotal() { return total; }
public Item getItem() { return item; }
public void setItem(Item item) {
this.item = item;
calculateTotal();
}
public int getQuantity() { return quantity; }
public void setQuantity(int quantity) {
this.quantity = quantity;
calculateTotal();
}
/* Public methods */
public void incrementQuantity() {
quantity++;
calculateTotal();
}
/**
* 計算item的金額
*/
private void calculateTotal() {
if (item != null && item.getListPrice() != null) {
total = item.getListPrice().multiply(new BigDecimal(quantity));
} else {
total = null;
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -