01: /*
02: * JFox - The most lightweight Java EE Application Server!
03: * more details please visit http://www.huihoo.org/jfox or http://www.jfox.org.cn.
04: *
05: * JFox is licenced and re-distributable under GNU LGPL.
06: */
07: package org.jfox.petstore.domain;
08:
09: import java.io.Serializable;
10:
11: import org.jfox.petstore.entity.Item;
12:
13: /**
14: * CartItem is not a Entity Object, just a logic domian Object contain Item and it's quantity
15: */
16: public class CartItem implements Serializable {
17:
18: /* Private Fields */
19:
20: private Item item;
21: private int quantity;
22: private boolean inStock;
23:
24: public boolean isInStock() {
25: return inStock;
26: }
27:
28: public void setInStock(boolean inStock) {
29: this .inStock = inStock;
30: }
31:
32: public Item getItem() {
33: return item;
34: }
35:
36: public void setItem(Item item) {
37: this .item = item;
38: }
39:
40: public int getQuantity() {
41: return quantity;
42: }
43:
44: public void setQuantity(int quantity) {
45: this .quantity = quantity;
46: }
47:
48: public double getTotalPrice() {
49: if (item != null) {
50: return item.getListPrice() * quantity;
51: } else {
52: return 0;
53: }
54: }
55:
56: public void incrementQuantity() {
57: quantity++;
58: }
59:
60: }
|