Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need help on my homework in java! Thanks to anyone who can help! And please kind

ID: 3668388 • Letter: N

Question

Need help on my homework in java! Thanks to anyone who can help! And please kindly comment and explain on the code just so i can understand it.

homework:

In the next four questions, write a complete class called Book (described below). A book is described by a title, author, publisher, and copyright year.

For full credit, follow good principles of class design and encapsulation.

I recommend writing the class in your development environment to make sure it compiles and then copying the code into the appropriate question

1. Write the class header and the instance data variables for the Book class.

A book is described by the title, author, publisher, and copyright year.

2.Write a constructor for the Book class. The constructor should initialize the instance data variables using parameters.

3.Write accessor and mutator (getter and setter) methods. Include validity checking where appropriate.

4. Write a toString method to return a nicely formatted, multi-line description of the book.

5. Write code that would go inside of a main method. The code should create two book objects and invoke at least two methods on each object. Also include a statement to print a text representation of each book to the console.

Explanation / Answer

public class Book
{
private String title;
private String author;
private String publisher;
private int crdate;
public Book(String title, String author, String publisher, int crdate)
{
this.title = title;
this.author = author;
this.publisher = publisher;
this.crdate = crdate;
}
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 getCrdate()
{
return crdate;
}
public void setCrdate(int crdate)
{
this.crdate = crdate;
}
public String toString()
{
String description = "";
description += "Title: " + title + " ";
description += "Author: " + author + " ";
description += "Publisher: " + publisher + " ";
description += "Copyright Date: " + crdate + " ";
return description;
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote