Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
224
Chapter 9 Session Tracking
Listing 9.8 ItemOrder.java
package coreservlets;
/** Associates a catalog Item with a specific order by
* keeping track of the number ordered and the total price.
* Also provides some convenience methods to get at the
* Item data without first extracting the Item separately.
*/
public class ItemOrder {
private Item item;
private int numItems;
public ItemOrder(Item item) {
setItem(item);
setNumItems(1);
}
public Item getItem() {
return(item);
}
protected void setItem(Item item) {
this.item = item;
}
public String getItemID() {
return(getItem().getItemID());
}
public String getShortDescription() {
return(getItem().getShortDescription());
}
public String getLongDescription() {
return(getItem().getLongDescription());
}
public double getUnitCost() {
return(getItem().getCost());
}
public int getNumItems() {
return(numItems);
}
public void setNumItems(int n) {
this.numItems = n;
}
Second edition of this book: www.coreservlets.com; Sequel: www.moreservlets.com.
Servlet and JSP training courses by book's author: courses.coreservlets.com.
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved