當前位置:成語大全網 - 漢語詞典 - 用java實現的電子詞典

用java實現的電子詞典

類別Book {//定義Book類別。

私有字符串bookName//書名

私有字符串作者;//作者

私有字符串發布者;//按下

私有字符串publishDate//出版日期

Public book (StringBookName,StringAuthor,StringPublisher,StringPublishDate){//構造函數。

this.setBookName(圖書名);

this.setAuthor(作者);

this.setPublisher(發布者);

this.setPublishDate(發布日期);

}

public void set bookName(String bookName){

this.bookName = bookName

}

公共字符串getBookName() {

返回圖書名稱;

}

public void setAuthor(字符串作者){

this.author =作者;

}

公共字符串getAuthor() {

返回作者;

}

public void setPublisher(字符串發布者){

this.publisher = publisher

}

公共字符串getPublisher() {

返回發布者;

}

public void setPublishDate(String publish date){

this . publish date = publish date;

}

公共字符串getPublishDate() {

返回發布日期;

}

公共字符串toString() {

return " |-Title:"+this . get bookname()+" \ n \ t "+" |-Author:"+this . get Author()+

" \ n \ t "+" |-Publisher:"+this . get Publisher()+" \ n \ t "+" |-發布日期:"+this . get publish date();

}

}

公共類書架{

公共靜態void main(String[] args) {

Book b1 =新書("書名1 ","作者1 ","出版社1 "," 2010-01 ");

system . out . println(b 1);

書b2 =新書("書名2 ","作者2 ","出版社2 "," 2065 438+00-02-02 ");

system . out . println(B2);

圖書b3 =新書("書名3 ","作者3 ","出版社3 "," 2065 438+00-03-03 ");

system . out . println(B3);

}

}