KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > samples > jpetstore > domain > CartItem


1 package org.springframework.samples.jpetstore.domain;
2
3 import java.io.Serializable JavaDoc;
4
5 public class CartItem implements Serializable JavaDoc {
6
7   /* Private Fields */
8
9   private Item item;
10   private int quantity;
11   private boolean inStock;
12
13   /* JavaBeans Properties */
14
15   public boolean isInStock() { return inStock; }
16   public void setInStock(boolean inStock) { this.inStock = inStock; }
17
18   public Item getItem() { return item; }
19   public void setItem(Item item) {
20     this.item = item;
21   }
22
23   public int getQuantity() { return quantity; }
24   public void setQuantity(int quantity) {
25     this.quantity = quantity;
26   }
27
28     public double getTotalPrice() {
29         if (item != null) {
30             return item.getListPrice() * quantity;
31         }
32         else {
33             return 0;
34         }
35     }
36
37   /* Public methods */
38
39   public void incrementQuantity() {
40     quantity++;
41   }
42
43 }
44
Popular Tags