Question: Wirte the java program In the above class diagram, the number of authors cannot be changed once a Book instance is constructed. Suppose that we

Wirte the java program

Wirte the java program In the above class diagram, the number of

authors cannot be changed once a Book instance is constructed. Suppose that

In the above class diagram, the number of authors cannot be changed once a Book instance is constructed. Suppose that we wish to allow the user to add more authors (which is really unusual but presented here for academic purpose). Instead of using a fixed-length array in this case, it is better to be a dynamically allocated array (e.g.. ArrayList), which does not have a fixed length. Modify the Book class. You should: Modify the authors array instance variable to an ArrayList Remove the authors from the parameter of the constructors, (don't forget to create a new instance of the authors ArrayList inside the constructors.) Add a new method called addAuthorQ to add the given Author instance to this Book. The toString() method shall return "book-name by n authors", where n is the number of authors. Modify the printAuthors() to print the names of all the authors from an ArrayList. Write the Book class in the answer box below assuming that the Author class has been done for you in the system. 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!