coreservlets
Class ShoppingCart
java.lang.Object
|
+--coreservlets.ShoppingCart
- public class ShoppingCart
- extends Object
A shopping cart data structure used to track orders.
The OrderPage servlet associates one of these carts
with each user session.
Taken from Core Servlets and JavaServer Pages
from Prentice Hall and Sun Microsystems Press,
http://www.coreservlets.com/.
© 2000 Marty Hall; may be freely used or adapted.
|
Constructor Summary |
ShoppingCart()
Builds an empty shopping cart. |
|
Method Summary |
void |
addItem(String itemID)
Looks through cart to see if it already contains
an order entry corresponding to item ID. |
Vector |
getItemsOrdered()
Returns Vector of ItemOrder entries giving
Item and number ordered. |
void |
setNumOrdered(String itemID,
int numOrdered)
Looks through cart to find order entry corresponding
to item ID listed. |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
ShoppingCart
public ShoppingCart()
- Builds an empty shopping cart.
getItemsOrdered
public Vector getItemsOrdered()
- Returns Vector of ItemOrder entries giving
Item and number ordered.
addItem
public void addItem(String itemID)
- Looks through cart to see if it already contains
an order entry corresponding to item ID. If it does,
increments the number ordered. If not, looks up
Item in catalog and adds an order entry for it.
setNumOrdered
public void setNumOrdered(String itemID,
int numOrdered)
- Looks through cart to find order entry corresponding
to item ID listed. If the designated number
is positive, sets it. If designated number is 0
(or, negative due to a user input error), deletes
item from cart.
 |
|---|
| CSAJSP @ amazon.com |
|---|