目录:
Book
package com.ys.book;
public class Book {
private String name;
private String author;
private int price;
private String type;
private boolean isBorrowed;
public Book(String name, String author, int price, String type) {
this.name = name;
this.author = author;
this.price = price;
this.type = type;
this.isBorrowed = isBorrowed;
}
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 int getPrice() {
return price;
}
public void setPrice(int 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;
}
@Override
public String toString() {
return "Book{" +
"name='" + name + '\'' +
", author='" + author + '\'' +
", price=" + price +
", type='" + type + '\'' +
", " + (isBorrowed ? "已经被借走":"未被借走") +
'}';
}
}
BookList
package com.ys.book;
public class BookList {
private Book[] books;
private int usedSize;
public BookList() {
this.books = new Book[10];
this.books[0] = new Book("三国演义","罗贯中",88,"小说");
this.books[1] = new Book("西游记","吴承恩",77,"小说");
this.books[2] = new Book("水浒传","施耐庵",66,"小说");
this.books[3] = new Book("红楼梦","曹雪芹",55,"小说");
this.use