Hi,
I'm having some difficulty with my shoppingCart. The method add2Cart should
check if the cart ( a hashtable ) already contains the product in question
before adding it. If it is already present in the cart,the Hashtable.remove()
method should get rid of it, and only put the new product/quantity in if the
quantity is greater than 0 (so that the order can be deleted by typing in 0).
Can anyone tell me if I'm using Hashtable.remove() correctly?
CartItem is a wrapper object, containing the order, the product and the
desired quantity of the product.
public void add2Cart(Product p, int quant) {
    if(cart.contains(p)){       // the new quantity should overide the old.
        cart.remove(p);         // so get rid of the old before putting in
the new
    }
    if(quant>0){
        cart.put(p,new CartItem(p,order,quant));
    }

}

Thanks
Peet

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to