用jsp实现一个简单的购物车web应用系统(Using JSP to implement a simple shopping cart web application system).docVIP

  • 21
  • 0
  • 约7.34千字
  • 约 23页
  • 2018-04-07 发布于江西
  • 举报

用jsp实现一个简单的购物车web应用系统(Using JSP to implement a simple shopping cart web application system).doc

用jsp实现一个简单的购物车web应用系统(Using JSP to implement a simple shopping cart web application system).doc

用jsp实现一个简单的购物车web应用系统(Using JSP to implement a simple shopping cart web application system) 1. in the establishment of their own WEB project, the establishment of packet shopcart.dto, in the corresponding package to add class Product.java, ShopCart.java The 1./* class Product. 2.3.package shopcart.dto; 4.5.import java.io.Serializable; 6.7.public class Product implements Serializable 8.{ 9. private String ID; / / String name private 10. product identification product name 11. private String; / / description; / / private double price 12. product description; / / public 13.14. Product (price) 15. { 16.} 17.18. public Product (String ID, String name, String description, double price) 19. { 20. this.id = id; 21. = name; 22. this.description = description; 23. this.price = price; 24.} 25.26. public void setId (String ID) 27. { 28. this.id = id; 29.} 30.31. public void setName (String name) 32. { 33. = name; 34.} 35.36. public void setDescription (String description) 37. { 38. this.description = description; 39.} 40.41. public void setPrice (double price) 42. { 43. this.price = price; 44.} 45.46. public String getId () 47. { 48. return id; 49.} 50.51. public String getName () 52. { 53. return name; 54.} 55.56. public String getDescription () 57. { 58. return description; 59.} 60.61. public double getPrice () 62. { 63. return price; 64.} 65.} The 66./* class ShopCart. 67.68.package shopcart.dto; 69.70.import java.io.Serializable; 71.import java.util.*; 72.73.public class ShopCart implements Serializable 74.{ 75. public ShopCart () 76. { 77.} 78.79. private List cart = null; 80.81. / * * 82. * add a product to a shopping cart 83. * @param product Product 84.. 85. public void addProductToCart (Product product) 86. { 87. if (CART = null) 88. cart = new ArrayList (); 89. Iterator it = cart.iterator (); 90. while (it.hasNext ()) 91. { 92. Product item = (Product) it.next (); 93. if (item.getId ().Equals (product.getId ())) 94. { 95. return; 96.} 97.} 98. cart.add (product); 99

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档