|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectope.shopping2.ShoppingCart
public class ShoppingCart
This class represents a shopping cart. A shopping cart has a customer as an owner and a list of products.
Customer
,
Product
Constructor Summary | |
---|---|
ShoppingCart()
Creates a new empty and anonymous shopping cart. |
Method Summary | |
---|---|
void |
addProduct(Product item)
Adds a product to the shopping cart if it is available. |
void |
clear()
Removes all the products from the shopping cart. |
int |
countProducts()
Returns the number of products in this shopping cart. |
Product |
getProduct(int index)
Returns a product at the given index in this shopping cart. |
double |
getTotalPrice()
Calculates the total price of products in this shopping cart. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ShoppingCart()
Method Detail |
---|
public void addProduct(Product item)
item
- the product to be added.public int countProducts()
public Product getProduct(int index)
index
- the index of the product.
public void clear()
public double getTotalPrice()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |