1.图书管理系统展示
这是最终效果展示,可以根据输入身份的不同,从而进入不同的身份内容去,不同的身份内容有不同的功能
2.图书管理系统实现
2.1 book包
2.1.1 Book类
书类中封装度很高,一般不露出任何一点成员变量
package book;
public class Book {
private String name;
private String author;
private double price;
private String type;
private boolean isBorrowed;
@Override
public String toString() {
return "Book{" +
"name='" + name + '\'' +
", author='" + author + '\'' +
", price=" + price +
", type='" + type + '\'' +
","+((isBorrowed==true)?"已借出":"未借出") +
'}';
}
public Book(String name, String author, double price, String type) {
this.name = name;
this.author = author;
this.price = price;
this.type = type;
}
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 double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public boolean isBorrowed() {
return isBorrowed;
}
public void setBorrowed(boolean borrowed) {
isBorrowed = borrowed;
}
}
2.1.1 BookList
BookList是一个书架,存储书,我们默认是10本书,并且给定三本默认的图书
package book;
public class BookList {
Book[] books = new Book[10];
private int usedSize;
public BookList() {
books[0] = new Book("三国演义","罗贯中",19,"小说");
books[1] = new Book("西游记","吴承恩",29,"小说");
books[2] = new Book("红楼梦","曹雪芹",9,"小说");
usedSize = 3;
}
public void setBooks(