KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jfox > petstore > domain > CartItem


1 /*
2  * JFox - The most lightweight Java EE Application Server!
3  * more details please visit http://www.huihoo.org/jfox or http://www.jfox.org.cn.
4  *
5  * JFox is licenced and re-distributable under GNU LGPL.
6  */

7 package org.jfox.petstore.domain;
8
9 import java.io.Serializable JavaDoc;
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 JavaDoc {
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         }
52         else {
53             return 0;
54         }
55     }
56
57     public void incrementQuantity() {
58         quantity++;
59     }
60
61 }
62
Popular Tags