book.java

来自「jsp实现的购物车功能」· Java 代码 · 共 69 行

JAVA
69
字号
package jspcart.books;import java.util.*;import jspcart.conn.*;import java.sql.*;public class Book {  private String bname;  private float price;  private int bnum;  private int ID;  public Book() {  }  public Book(int id,String name,float price,int num){    this.setID(id);    this.setBname(name);    this.setPrice(price);    this.setBnum(num);  }  public int getID() {   return ID; } public void setID(int ID) {   this.ID = ID; }  public String getBname() {    return bname;  }  public void setBname(String bname) {    this.bname = bname;  }  public float getPrice() {    return price;  }  public void setPrice(float price) {    this.price = price;  }  public int getBnum() {    return bnum;  }  public void setBnum(int bnum) {    this.bnum = bnum;  }  //获取所有货物  public List getBooks(DBConnection db){    List l=new ArrayList();    String sql="select * from product";    ResultSet rst=null;    rst=db.Execsql(sql);    try {      while(rst.next()){        int bid=rst.getInt(1);        String bname=rst.getString(2);        float bprice=rst.getFloat(3);        int bnum=rst.getInt(4);        Book book=new Book(bid,bname,bprice,bnum);        l.add(book);      }    }    catch (Exception ex) {      ex.printStackTrace();    }    return l;  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?