这里的商品实例也就是书籍。我们会将其构建为一个javaBean类,以提高代码的重复利用性和程序的可维护性。这里有个小技巧用于迅速添加大量的setter和getter:右键你的类名,然后在弹出菜单中选择:”Source” -> “Generate Getters and Setters” -> “Select All” -> “OK”。
package entity;import java.util.Date;public class Book {// 书籍的相关属性,这里需要设置为私有权限 PRivate String isbn; private String name; private String author; private String intro; //书籍简介 private float price_original; private float price; private String publish_comany; private Date publish_time; private String img_path;// 共有无参构造函数 public Book(){ }// 所有属性的getter和setter public String getIsbn() { return isbn; } public void setIsbn(String isbn) { this.isbn = isbn; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getAuthor() { return author; } public void setAuthor(String author) { this.author = author; } public String getIntro() { return intro; } public void setIntro(String intro) { this.intro = intro; } public float getPrice_original() { return price_original; } public void setPrice_original(float price_original) { this.price_original = price_original; } public float getPrice() { return price; } public void setPrice(float price) { this.price = price; } public String getPublish_comany() { return publish_comany; } public void setPublish_comany(String publish_comany) { this.publish_comany = publish_comany; } public Date getPublish_time() { return publish_time; } public void setPublish_time(Date publish_time) { this.publish_time = publish_time; } public String getImg_path() { return img_path; } public void setImg_path(String img_path) { this.img_path = img_path; }}你可以在点击这里查看更多关于JavaBean的知识。
新闻热点
疑难解答