using Java Question 3: (practice to write the code for accessor methods, method
ID: 3851685 • Letter: U
Question
using Java
Explanation / Answer
public class TheBook {
//private data members
private String title;
private String bookId;
private String ISBN
private String writer;
private String publisher;
public TheBook(){}
public TheBook(String title, String bookId, String ISBN, String writer, String publisher) {
this.title = title;
this.bookId = bookId;
this.ISBN = ISBN;
this.writer = writer;
this.publisher = publisher;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getbookId() {
return bookId;
}
public void setbookId(String bookId) {
this.bookId = bookId;
}
public String getISBN() {
return ISBN;
}
public void setISBN(String bookId) {
this.ISBN = ISBN;
}
public String getwriter() {
return writer;
}
public void setwriter(String writer) {
this.writer = writer;
}
public String getPublisher() {
return publisher;
}
public void setPublisher(String publisher) {
this.publisher = publisher;
}
/**
* Returns String description of TheBook.
*/
public String toString() {
String description = "";
description += "Book Title: " + title + " ";
description += "Book ID: " + bookId + " ";
description += "Book ISBN: " + ISBN + " ";
description += "Writer: " + Writer + " ";
description += "publisher: " + publisher + " ";
return description;
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.