Shopping Cart code of J2EE Course Design (limited level, for reference only)

Source: Internet
Author: User

  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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.