Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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. b) Implement an addBook() method which tries to create a new Book and adds it to the Bookstore. The addBook() method should accept parameters for the new Book authors first and last names, the title of the book, and the year published; it must also catch any thrown Exceptions. c) Implement a displayBooks() method which prints books before and after sorting them.

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Instant Reference

Authors: Gruber, Martin Gruber

2nd Edition

0782125395, 9780782125399

More Books

Students also viewed these Databases questions

Question

What is the current year you are evaluating?

Answered: 1 week ago