Question: Help to answer the java question. A class called Book is designed as shown in the class diagram. A book can be written by one

Help to answer the java question.

Help to answer the java question. A class called Book is designedas shown in the class diagram. A book can be written by

A class called Book is designed as shown in the class diagram. A book can be written by one or more authors by using an ArrayList for the instance variable authors. Write the Book class in the answer box below assuming that the Author class has been done for you in the system. You should: Create a new instance of the authors ArrayList inside the constructors. Implement a method addAuthor(Author author) to add the given Author instance to this Book. Implement a public method removeAuthorByName(String name) that uses the given String to search the authors ArrayList. If it finds an Author object with a name matching the given String it passes the reference to this object to a private method removeAuthor(Author author). Implement a public method removeAuthorByEmail(String email) that uses the given String to search the authors ArrayList. If it finds an Author object with an email matching the given String it passes the reference to this object to a private method removeAuthor(Author author). Implement a private method removeAuthor(Author author) which when given a reference to an Author object removes the reference to that object from the authors ArrayList. The toString() method shall return "book-name by n authors", where n is the number of authors. The printAuthors() method shall print the names of all the authors from an Arraylist. For example

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!