KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > olstore > dto > ShoppingCartItem


1 /**
2  * Copyright (c) 2004 Red Hat, Inc. All rights reserved.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17  * USA
18  *
19  * Component of: Red Hat Application Server
20  *
21  * Initial Developers: Aizaz Ahmed
22  * Vivek Lakshmanan
23  * Andrew Overholt
24  * Matthew Wringe
25  *
26  */

27 package olstore.dto;
28 import java.io.Serializable;
29 import java.math.BigDecimal;
30
31 import olstore.entity.ItemLocal;
32
33 public class ShoppingCartItem implements Serializable{
34     private Integer itemId;
35     private String name;
36     private BigDecimal price;
37     private BigDecimal unitPrice;
38     // Should have been float, however, illegal input like strings in quantity
39
// text box result in the interpretation of such input as 0 and that has
40
// special meaning for the checkout system
41
// (suggests removal of the item) so in order to avoid such awkwardness
42
// quantity was converted to being a String.
43
private String quantity;
44     
45     public ShoppingCartItem(){
46         itemId = null;
47         name = null;
48         price = null;
49         quantity = null;
50     }
51     
52     public ShoppingCartItem(ItemLocal item){
53         itemId = item.getItemId();
54         name = item.getName();
55         unitPrice = item.getPrice();
56         price = new BigDecimal(0);
57     }
58     
59     public String toString(){
60         return ("itemId="+ itemId + "\tname=" + name + "\tprice=" + price + "\tunitPrice=" + unitPrice + "\tquantity=" + quantity);
61         
62     }
63     
64     public Integer getItemId(){
65         return itemId;
66     }
67     
68     public String getName () {
69         return name ;
70     }
71     
72     public void setName ( String name) {
73         this.name = name;
74     }
75     
76     public BigDecimal getPrice () {
77         return price;
78     }
79     
80     public void setPrice ( BigDecimal price ) {
81         this.price = price;
82     }
83     
84     public String getQuantity () {
85         return quantity;
86     }
87     
88     public void setQuantity ( String quantity) {
89         this.quantity = quantity;
90     }
91     
92     
93 }
94
Popular Tags