图个管理系统之实体类的设计

  • Post author:
  • Post category:其他


本系统设计到6个实体类,分别为:Book.java,BookType.java,Borrow,Book.java,Reader.java,ReaderType.java,Users.java,实体类的雷明应该与数据库的类名一致,然后里面添加每个表(实体类)里的属性(类型和名字与数据库要一致),最后添加gets和sets方法,无需自己添加,在eclipse里只要选中所有属性,然后右键——>Source——>Generate  Getters and  Setters 选中后点击select    all就可以创建所有的方法。

以下是本项目的工程名称及包名和用到的图片,所有的内容均可根据自己的喜好进行修改


1、Book.java

package pdsu.bbm.model;

import java.util.Date;

public class Book {




private String ISBN; // 图书isbn号



private String typeid; // 图书类型名称



private String bookname; // 图书名



private String author; // 作者



private String publish; // 出版社



private Date publishdate; // 出版日期



private int publishtime; // 印刷次数



private int unitprice; // 图书单价



private String typename;



public String getISBN() {




return ISBN;



}



public String getTypename() {




return typename;



}



public void setTypename(String typename) {




this.typename = typename;



}



public void setISBN(String iSBN) {




ISBN = iSBN;



}



public String getTypeid() {




return typeid;



}



public void setTypeid(String typeid) {




this.typeid = typeid;



}



public String getBookname() {




return bookname;



}



public void setBookname(String bookname) {




this.bookname = bookname;



}



public String getAuthor() {




return author;



}



public void setAuthor(String author) {




this.author = author;



}



public String getPublish() {




return publish;



}



public void setPublish(String publish) {




this.publish = publish;



}



public Date getPublishdate() {




return publishdate;



}



public void setPublishdate(Date date) {




this.publishdate = date;



}



public int getPublishtime() {




return publishtime;



}



public void setPublishtime(int publishtime) {




this.publishtime = publishtime;



}



public int getUnitprice() {




return unitprice;



}



public void setUnitprice(int unitprice) {




this.unitprice = unitprice;



}



public String toString() {




return “Book [ISBN=” + ISBN + “, typeid=” + typeid + “, bookname=”



+ bookname + “, author=” + author + “, publish=” + publish



+ “, publishdate=” + publishdate + “, publishtime=”



+ publishtime + “, unitprice=” + unitprice + “]”;



}

}

2、BookType.java

package pdsu.bbm.model;

public class BookType {




private int id; // 图书类型编号



private String typename;// 图书类型名称



public int getId() {




return id;



}



public void setId(int id) {




this.id = id;



}



public String getTypename() {




return typename;



}



public void setTypename(String typename) {




this.typename = typename;



}



public String toString() {




return “BookType [id=” + id + “, typename=” + typename + “]”;



}

}

3、BorrowBook.java

package pdsu.bbm.model;

import java.util.Date;

public class BorrowBook {




private String readerid; // 读者编号



private String ISBN; // 图书isbn编号



private Date borrowdate; // 借书日期



private Date returndate; // 还书日期



private int fine; // 罚金



private String bookname;



private String author;



private String publish;



private Date publishDate;



private String typename;



private int price;



private int publishtime;



public int getPublishtime() {




return publishtime;



}



public void setPublishtime(int publishtime) {




this.publishtime = publishtime;



}



public Date getPublishDate() {




return publishDate;



}



public String getTypename() {




return typename;



}



public void setTypename(String typename) {




this.typename = typename;



}



public void setPublishDate(Date publishDate) {




this.publishDate = publishDate;



}



public String getReaderid() {




return readerid;



}



public void setReaderid(String readerid) {




this.readerid = readerid;



}



public String getISBN() {




return ISBN;



}



public void setISBN(String iSBN) {




ISBN = iSBN;



}



public Date getBorrowdate() {




return borrowdate;



}



public void setBorrowdate(Date borrowdate) {




this.borrowdate = borrowdate;



}



public Date getReturndate() {




return returndate;



}



public void setReturndate(Date returndate) {




this.returndate = returndate;



}



public int getFine() {




return fine;



}



public void setFine(int fine) {




this.fine = fine;



}



public String getBookname() {




return bookname;



}



public void setBookname(String bookname) {




this.bookname = bookname;



}



public String getAuthor() {




return author;



}



public void setAuthor(String author) {




this.author = author;



}



public String getPublish() {




return publish;



}



public void setPublish(String publish) {




this.publish = publish;



}



public int getPrice() {




return price;



}



public void setPrice(int price) {




this.price = price;



}



@Override



public String toString() {




return “BorrowBook [readerid=” + readerid + “, ISBN=” + ISBN + “, borrowdate=” + borrowdate + “, returndate=”



+ returndate + “, fine=” + fine + “]”;



}

}

4、Reader.java

package pdsu.bbm.model;

import java.util.Date;

public class Reader {




private String readerid; // 读者编号



private int type; // 读者类型



private String name; // 读者姓名



private int age; // 年龄



private String sex; // 性别



private String phone; // 电话



private String dept; // 所在院系



private Date regDate; // 注册日期



private String typename;



private int limit;



private int maxborrownum;



public String getReaderid() {




return readerid;



}



public void setReaderid(String readerid) {




this.readerid = readerid;



}



public int getType() {




return type;



}



public void setType(int type) {




this.type = type;



}



public String getName() {




return name;



}



public void setName(String name) {




this.name = name;



}



public int getAge() {




return age;



}



public void setAge(int age) {




this.age = age;



}



public String getSex() {




return sex;



}



public void setSex(String sex) {




this.sex = sex;



}



public String getPhone() {




return phone;



}



public void setPhone(String phone) {




this.phone = phone;



}



public String getDept() {




return dept;



}



public void setDept(String dept) {




this.dept = dept;



}



public Date getRegDate() {




return regDate;



}



public void setRegDate(Date regDate) {




this.regDate = regDate;



}



public String getTypename() {




return typename;



}



public void setTypename(String typename) {




this.typename = typename;



}



public int getLimit() {




return limit;



}



public void setLimit(int limit) {




this.limit = limit;



}



public int getMaxborrownum() {




return maxborrownum;



}



public void setMaxborrownum(int maxborrownum) {




this.maxborrownum = maxborrownum;



}



public String toString() {




return “Reader [readerid=” + readerid + “, type=” + type + “, name=” + name + “, age=” + age + “, sex=” + sex



+ “, phone=” + phone + “, dept=” + dept + “, regDate=” + regDate + “, typename=” + typename + “, limit=”



+ limit + “, maxborrownum=” + maxborrownum + “]”;



}

}

5、ReaderType.java

package pdsu.bbm.model;

public class ReaderType {




private int id; // 读者类型编号



private String typename; // 读者类型名称



private int maxborrownum; // 最大借书量



private int limit; // 最长借阅天数



public int getId() {




return id;



}



public void setId(int id) {




this.id = id;



}



public String getTypename() {




return typename;



}



public void setTypename(String typename) {




this.typename = typename;



}



public int getMaxborrownum() {




return maxborrownum;



}



public void setMaxborrownum(int maxborrownum) {




this.maxborrownum = maxborrownum;



}



public int getLimit() {




return limit;



}



public void setLimit(int limit) {




this.limit = limit;



}

}

6、Users.java

package pdsu.bbm.model;

public class Users {




private int id; // 用户编号



private String name; // 用户名



private String password;// 密码



public int getId() {




return id;



}



public void setId(int id) {




this.id = id;



}



public String getName() {




return name;



}



public void setName(String name) {




this.name = name;



}



public String getPassword() {




return password;



}



public void setPassword(String password) {




this.password = password;



}

}



版权声明:本文为MyLove621原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。