Question: BASE CODE : Book.java import java.time.LocalDate; public abstract class Book { private int year; private int month; private int day; private String bookTitle; private String
BASE CODE :
Book.java
import java.time.LocalDate;
public abstract class Book { private int year; private int month; private int day; private String bookTitle; private String bookAuthor; private static int id; // static variable initialised for book id number private int bookId=0; // constructor public Book(String title, String author, int year, int month, int day) throws InvalidDateException { id++; bookId=id; //book id incremented bookTitle = title; bookAuthor = author; this.year=year; this.month=month; this.day=day; } // get bookTitle public String getbookTitle() { return bookTitle; } public int getYear() { return year; } public int getMonth() { return month; } public int getDay() { return day; } // get bookAuthor public String getbookAuthor() { return bookAuthor; } public String toString() { return bookTitle + " " + bookAuthor + " "+ year + " " + month + " " + day + " " +bookId; } }
Novel.java
import java.time.LocalDate; import java.util.Calendar;
public final class Novel extends Book { private double bookCost; int currYear = Calendar.getInstance().get(Calendar.YEAR); // constructor for class Novel public Novel(String title, String author, double cost, int year,int month,int day) throws InvalidDateException { super(title, author, year, month, day); // call superclass constructor setBookCost(cost); if(currYear - this.getYear() 12) { throw new InvalidDateException ("Month is out of range"); } } // set Novel's cost public void setBookCost(double cost) { bookCost = cost; } // get String representation of book details public String toString() { return "Novel: " + super.toString(); } } // end class Novel
InvalidDateException.java
public class InvalidDateException extends RuntimeException { public InvalidDateException (String message) { super(message); } }
If else exception statements required in the constructor of the novel class for the following and also print out the details of the book as well as the exception.

if day is out of range according to the month (1 point) if day falls on the weekend (1 point) (books aren't published on weekends) The exception should have a message with the book details and a short description of the problem (2 points)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
