编写book.java_编写一个javabean命名为:Book.java属性包括:
时间: 2024-03-20 10:39:12 浏览: 101
好的,以下是一个可能的 Book.java 的实现,包含了一些常见的属性:
```java
public class Book {
private String title;
private String author;
private String publisher;
private int publicationYear;
private int pageCount;
private String isbn;
// 构造函数
public Book(String title, String author, String publisher, int publicationYear, int pageCount, String isbn) {
this.title = title;
this.author = author;
this.publisher = publisher;
this.publicationYear = publicationYear;
this.pageCount = pageCount;
this.isbn = isbn;
}
// getter 和 setter 方法
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public String getPublisher() {
return publisher;
}
public void setPublisher(String publisher) {
this.publisher = publisher;
}
public int getPublicationYear() {
return publicationYear;
}
public void setPublicationYear(int publicationYear) {
this.publicationYear = publicationYear;
}
public int getPageCount() {
return pageCount;
}
public void setPageCount(int pageCount) {
this.pageCount = pageCount;
}
public String getIsbn() {
return isbn;
}
public void setIsbn(String isbn) {
this.isbn = isbn;
}
}
```
这个 Book 类的属性包括:
- title:书的标题,类型为 String
- author:作者姓名,类型为 String
- publisher:出版社,类型为 String
- publicationYear:出版年份,类型为 int
- pageCount:页数,类型为 int
- isbn:ISBN 编号,类型为 String
同时提供了构造函数和 getter/setter 方法以便使用。
阅读全文