Methods Summary |
---|
public java.util.Enumeration | getProducts()Returns the product list.
return cart.elements();
|
public float | getTotal()Returns the total price for all products in the cart
float total = 0;
Enumeration prods = getProducts();
while (prods.hasMoreElements()) {
ProductBean product = (ProductBean) prods.nextElement();
float price = product.getPrice();
total += price;
}
return total;
|
public boolean | isEmpty()Returns true if the cart is empty
return cart.size() == 0;
|
public void | setProduct(ProductBean product)Adds a product to the cart, if it's not already there.
if (product != null && cart.indexOf(product) == -1) {
cart.addElement(product);
}
|