Question: Library The Library class should have two fields: an array of Book objects called books, and an integer, numBooks, to keep track of how many

Library
The Library class should have two fields: an array of Book objects called books, and an integer, numBooks, to keep track of how many books are in the array.
The Library class should have the following methods:
A constructor. The Library should have a constructor, which creates the books array, to hold 50 books, and then calls the loadLibrary method. You may have the filename written directly into the constructor (you dont need to ask the user for it).
private void loadLibrary(String filename). This method should open the file passed in as a parameter, and read the information about each book. The file format is:
AuthorFirstName AuthorLastName Length Year Title
with a space between each piece of information. Only the title may have spaces in it. For example:
Jane Austin 4801813 Pride and Prejudice
Read each book in from the file, and add it to the books array. You may assume that the file is correctly formatted (there wont be errors in the file). If there are more than 50 books in the file, it should stop after reading the 50 books and continue the rest of the program (without displaying an error).
public Book newest(). This method should return the book object of the newest/youngest. Note that this should return a Book object, not just a String with the name in it.
public double averageLength(). This method should return the average length of all books in the library. This should return a double, so be sure it doesnt round the correct answer to an integer.
public void searchForAuthor(String author). This method should search for the specified author, and display the titles, number of pages, and year for books of theirs in a neatly formatted table (you do not need to have a header at the top which labels the columns). If no books are found, display a message stating that there are no books by that author.

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!