/* * PP4.4 - Design and implement a class called Book that contains * instance data for the title, author, publisher, and copyright * date. Define the Book constructor to accept and initialize this * data. Include setter and getter methods for all instance data. * Include a toString method that returns a nicely formatted , * multi-line description of the book. Create a driver class * called BookShelf, whose main method instantiates and updates * several Book objects. */ public class Book { //private data members private String title; private String author; private String publisher; private int crdate; /** * Constructor * @param title * @param author * @param publisher * @param crdate */ public Book(String title, String author, String publisher, int crdate) { this.title = title; this.author = author; this.publisher = publisher; this.crdate = crdate; } /** * Returns title * @return title */ public String getTitle() { return title; } /** * Updates title * @param title */ public void setTitle(String title) { this.title = title; } /** * Returns author * @return author */ public String getAuthor() { return author; } /** * Updates author * @param author */ public void setAuthor(String author) { this.author = author; } /** * Returns publisher * @return publisher */ public String getPublisher() { return publisher; } /** * Updates publisher * @param publisher */ public void setPublisher(String publisher) { this.publisher = publisher; } /** * Returns copyright date * @return crdate */ public int getCrdate() { return crdate; } /** * Updates copyright date * @param crdate */ public void setCrdate(int crdate) { this.crdate = crdate; } /** * Returns String description of Book. */ public String toString() { String description = ""; description += "Title: \t" + title + "\n"; description += "Author: \t" + author + "\n"; description += "Publisher: \t" + publisher + "\n"; description += "Copyright Date: \t" + crdate + "\n"; return description; } }