Book Class 1) Create an abstract class named Book a. Include fields for title, p
ID: 3711905 • Letter: B
Question
Book Class 1) Create an abstract class named Book a. Include fields for title, price, and publishingDate b. Include a constructor that requires the book title, isbn, and date of publishing. 2) Adkl get methods to return title, isbn, publisher, price, and date of publishing. Include set methods for title, isbn, publisher, price, and date of publishing. ) Set method for price is an ahstract method 5) Include an abstract method calculateCharge that accepes quantity sold and returns total 6) Include toString0 method. Spring 2018 MIS 120 isbn: String publisher: String price: double quantty int +Book (t: String, i: String. dop +getTitle(: String +sett lelt: Stringl: void +seti5BN (ison: String): void +getiSBN 0:String +setPublisher (p : String) : woid +getPublisher O :String +setPublishDate(dop:Date): void getPrice0: double + getQuantty): int +setOuantityiq: int) void price:double Fiction t:String,:String, pub : String,NonFictiont:String,i:String dop Date, p:double) + setPricelp: double) void pub: String, dop Date, p: double) +setPricelp: double): void Fiction and NonPiction Classes 1) Create two sub classes of Book: Fiction and NonFiction. a. Each must include a setPrice0 method that sets the price. b. Include calculateCharge method in each of the subdasses that implements calculateCharge from Book class. Include 7.25% tax for Fiction books. There is not tax for Non Fiction books c. Indlude toString in each class. d. Write a constructor for each subelass, and include a call to setPrice) within each. 2) Write a demo program called BooksDemo a. Create one fiction and one non fiction book and display all fields using toStringO Spring 2018 MIS 120 Sample Output Fiction Title The Hideaway ISBN0718084225 Publication Date: April 11, 2017 Publisher: Thonas Ne1son Price 9.23 Quantity5Explanation / Answer
Book.java
import java.util.Date;
public abstract class Book{
private String title, isbn, publisher;
protected double price;
private int quantity;
private Date publishDate;
public Book(String title, double price, Date publishDate) {
super();
this.title = title;
this.price = price;
this.publishDate = publishDate;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getIsbn() {
return isbn;
}
public void setIsbn(String isbn) {
this.isbn = isbn;
}
public String getPublisher() {
return publisher;
}
public void setPublisher(String publisher) {
this.publisher = publisher;
}
public int getQuantity() {
return quantity;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
}
public Date getPublishDate() {
return publishDate;
}
public double getPrice() {
return price;
}
public void setPublishDate(Date publishDate) {
this.publishDate = publishDate;
}
abstract double calculateCharge();
@Override
public String toString() {
return "Book [title=" + title + ", isbn=" + isbn + ", publisher=" + publisher + ", price=" + price
+ ", quantity=" + quantity + ", publishDate=" + publishDate + "]";
}
}
Fiction.java
import java.util.Date;
public class Fiction extends Book{
public Fiction(String title, double price, Date publishDate) {
super(title, price, publishDate);
this.setPrice(price);
}
@Override
double calculateCharge() {
double cost = this.getPrice() + (this.getPrice() * 0.0725);
return cost;
}
@Override
public String toString() {
return "Fiction [Charge=" + calculateCharge() + ", Title=" + getTitle() + ", ISBN="
+ getIsbn() + ", Publisher=" + getPublisher() + ", Price=" + getPrice() + ", Quantity="
+ getQuantity() + ", Publish Date=" + getPublishDate() + "]";
}
public void setPrice(double price) {
this.setPrice(price);
}
}
NonFiction.java
import java.util.Date;
public class NonFiction extends Book{
public NonFiction(String title, double price, Date publishDate) {
super(title, price, publishDate);
this.setPrice(price);
}
@Override
double calculateCharge() {
return this.getPrice();
}
@Override
public String toString() {
return "Non Fiction [Charge=" + calculateCharge() + ", Title=" + getTitle() + ", ISBN="
+ getIsbn() + ", Publisher=" + getPublisher() + ", Price=" + getPrice() + ", Quantity="
+ getQuantity() + ", Publish Date=" + getPublishDate() + "]";
}
public void setPrice(double price) {
this.setPrice(price);
}
}
**Comment for any further queries.