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


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
Get step-by-step solutions from verified subject matter experts
