|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectch7.catalog.ShoppingCart<Item>
Item - public class ShoppingCart<Item>
A generic class for a shopping cart.
The class can store any type of item. It allows for adding an item and clearing all items. Additional helpers have been added just to show that the cart can have any kind of additional functionality.
| Constructor Summary | |
|---|---|
ShoppingCart()
Creates a new instance of ShoppingCart |
|
| Method Summary | |
|---|---|
void |
addItem(Item item)
Add an item to the cart. |
void |
addTotal(double amount)
Add an amount to the total. |
int |
getCount()
Accessor for the count of items in the cart. |
java.util.List<Item> |
getItems()
Retrieve a list of all the items in the cart. |
double |
getTotal()
Retrieve the total price for the cart. |
java.lang.String |
getTotalAsCurrency()
Retrieve the total as currency. |
void |
incrCount()
Increment the count. |
void |
resetItems()
Release all the items from the shopping cart. |
void |
setCount(int count)
Set the count for the cart. |
void |
setItems(java.util.List<Item> items)
Set all the items in the shopping cart from a list of items. |
void |
setTotal(double total)
Set the total price for the cart. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ShoppingCart()
| Method Detail |
|---|
public void resetItems()
public void setItems(java.util.List<Item> items)
items - Element data from the requestpublic java.util.List<Item> getItems()
public void addItem(Item item)
item - Element data from the requestpublic void setTotal(double total)
total - Element data from the requestpublic double getTotal()
public void setCount(int count)
The count could be different from the actual number of items in the cart, if a feature is added to allow multiple numbers of an item.
count - Element data from the requestpublic int getCount()
public void addTotal(double amount)
amount - Element data from the requestpublic java.lang.String getTotalAsCurrency()
public void incrCount()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||