CartAction setBook_id(.book_id = setNum(.num = .bookname = .author = .publisher = .isbn = setPrice(.price = .picture = setQty(.qty = =<Cart> list=(List<Cart>)session.get("cart_list" size==0(size==1=list.get(0).getPrice()*list.get(0"total"( i=0;i<size;i++=total+list.get(i).getPrice()*"total" setTotal(.total ==<Cart> list=(List<Cart>)session.get("cart_list"= (list=="null"= ArrayList<Cart> (search(list)!=-1 i="contains"=++"add""cart_list" "cart"=<Cart> list=(List<Cart>)session.get("cart_list" i=="cart_list" "cart"=<Cart> list=(List<Cart>)session.get("cart_list" i="cart_list" "cart" search(List<Cart> size=(size==1(list.get(0).getBook_id()== 0( i=0;i<size;i++(list.get(i).getBook_id()== -1
Here is the cart implemented using ArrayList:
GetTotal () calculates the total cost of books in the shopping cart;
Add () add a book to the shopping cart;
Edit () modify the number of books in the shopping cart;
Del () delete books in the shopping cart;
Search (List <Cart> list) is my original, used to determine whether a book with a specific id exists in the shopping Cart.
If you need complete source code, contact me.