KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.springframework.samples.jpetstore.domain;
2
3 import java.io.Serializable JavaDoc;
4
5 public class LineItem implements Serializable JavaDoc {
6
7   /* Private Fields */
8
9   private int orderId;
10   private int lineNumber;
11   private int quantity;
12   private String JavaDoc itemId;
13   private double unitPrice;
14   private Item item;
15
16   /* Constructors */
17
18   public LineItem() {
19   }
20
21   public LineItem(int lineNumber, CartItem cartItem) {
22     this.lineNumber = lineNumber;
23     this.quantity = cartItem.getQuantity();
24     this.itemId = cartItem.getItem().getItemId();
25     this.unitPrice = cartItem.getItem().getListPrice();
26     this.item = cartItem.getItem();
27   }
28
29   /* JavaBeans Properties */
30
31   public int getOrderId() { return orderId; }
32   public void setOrderId(int orderId) { this.orderId = orderId; }
33
34   public int getLineNumber() { return lineNumber; }
35   public void setLineNumber(int lineNumber) { this.lineNumber = lineNumber; }
36
37   public String JavaDoc getItemId() { return itemId; }
38   public void setItemId(String JavaDoc itemId) { this.itemId = itemId; }
39
40   public double getUnitPrice() { return unitPrice; }
41   public void setUnitPrice(double unitprice) { this.unitPrice = unitprice; }
42
43   public Item getItem() { return item; }
44   public void setItem(Item item) {
45     this.item = item;
46   }
47
48   public int getQuantity() { return quantity; }
49   public void setQuantity(int quantity) {
50     this.quantity = quantity;
51   }
52
53     public double getTotalPrice() {
54         return this.unitPrice * this.quantity;
55     }
56
57 }
58
Popular Tags