Question
Using Java to create the following classes below. 1. Create a Book class: a) There are fields for the authors first and last names (use
Using Java to create the following classes below.
1. Create a Book class:
a) There are fields for the authors first and last names (use a Name class you create), the title of the book (make this protected, not private), and the year published (an int). b) Create a constructor that accepts parameters for all four fields. c) The constructor must call its own mutator methods for the following behaviors (d, e, below). d) The setYearPublished mutator must throw an InvalidBookDateException (you will have to create this class) if the date parameter is greater than 2016. e) The setFirstName, setLastName, and setTitle mutators must throw an InvalidArgumentException (you will have to create this class) if their parameter is null or an empty string. Call these methods from the constructor. f) Provide accessors, mutators, equals(), hashCode(), and a toString() method. The accessors and mutators are final. g) Implement Comparable; more-recent books are bigger.
2. Create a Bookstore class:
a) There is a single field which is an ArrayList
3. Create a Biography class, which is final. It extends Book. It adds a field called subject which is a Name object. Override equals again; books are equal if they are biographies of the same subject.
And Obviously a Main class(tester) if it needs one.
Please follow all the instructions above to be rated.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started