2 Star 0 Fork 0

20155207wxc/besti-java-20155207wxc

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Book.java 1.70 KB
一键复制 编辑 原始数据 按行查看 历史
lnaswxc 提交于 2017-06-07 09:22 . 第十六周课上
public class Book { //定义Book类
private String bookName; //书名
private String author; //作者
private String publisher; //出版社
private String publishDate; //出版日期
public Book(String bookName, String author, String publisher, String publishDate) { //构造方法
this.setBookName(bookName);
this.setAuthor(author);
this.setPublisher(publisher);
this.setPublishDate(publishDate);
}
public void setBookName(String bookName) {
this.bookName = bookName;
}
public String getBookName() {
return bookName;
}
public void setAuthor(String author) {
this.author = author;
}
public String getAuthor() {
return author;
}
public void setPublisher(String publisher) {
this.publisher = publisher;
}
public String getPublisher() {
return publisher;
}
public void setPublishDate(String publishDate) {
this.publishDate = publishDate;
}
public String getPublishDate() {
return publishDate;
}
public String toString() {
return "书名:" + this.getBookName() + "\n\t" + "作者:" + this.getAuthor() +
"\n\t" + "出版社:" + this.getPublisher() + "\n\t" + "出版日期:" + this.getPublishDate();
}
public static void main(String[] args) {
Book b1 = new Book("书名1", "作者1", "出版社1", "2010-01-01");
System.out.println(b1);
Book b2 = new Book("书名2", "作者2", "出版社2", "2010-02-02");
System.out.println(b2);
Book b3 = new Book("书名3", "作者3", "出版社3", "2010-03-03");
System.out.println(b3);
}
}
}}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/lnaswxc/besti-java-20155207wxc.git
git@gitee.com:lnaswxc/besti-java-20155207wxc.git
lnaswxc
besti-java-20155207wxc
besti-java-20155207wxc
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385