- Create “New Class…†named Book tostore the details of a book
- Declare 3 fields for the details of the book:
- field named author of typeString
- field named title of typeString
- field named callNumber of typeString
- Add overloaded constructors with the following headers and makesure each constructor has only 1 statement in thebody that makes an internal method call tosetBookDetails:
- public Book(String author, String title, StringcallNumber)
- public Book(String author, Stringtitle)
HINT: Initializethe callNumber field to an emptyString in #2 constructor
- Add accessor method getAuthor toreturn the author field
- Add accessor method getTitle toreturn the title field
- Add accessor method getCallNumber toreturn callNumber field
- Add accessor method getBookDetails toreturn a String in the format:
“ :  ()â€
HINT: Complete withONLY 1 line of code using String concatenation
- Add mutator method setBookDetailswith the following header to will initialize the fields to theseparameters of the same name:
     public voidsetBookDetails(String author, String title, StringcallNumber)                  Â
NOTE: Use method callgetBookDetails where the detailsof a book are needed (i.e. when listing/printing books or supplyinginformation about a particular book)
- Create “New Class…†named Genre tostore a group of books
- Import all necessary Java package library classes
- Declare 2 fields for each genre:
- field named genreName of typeString
- field named books of typeArrayList of Book
- Write a constructor (with the following header) to initializeBOTH fields
publicGenre(String genreName)
HINT: Make sure youinstantiate a newbooks ArrayList object
- Add accessor method getGenreName toreturn the genreName field
- Add accessor getGenreBooks to returnthe books field
- Add accessor getNumberOfGenreBooksreturning # of items in the books
- Add a method (with header below) to check if an index is validin books
public booleanbookIndexValid(int index)
HINT: First makesure books collection is NOTnull or empty
- Overload method addGenreBook (withthe following headers) to add a new book to the genre using theArrayList .add method
- public void addGenreBook(Bookbook)
- public void addGenreBook(String author,Stringtitle,String callNumber)
HINT: Make sure youcreate a new Book object in #2
- Add method to return the index (or–1, if not found) of the FIRST book in ArrayListbooks that EXACTLY matches a particularcallNumber
publicint findGenreBookWithCallNumber(StringcallNumber)
- Use 2 local variables (index andsearching) along with a whileloop
- (Only after ENTIRE search loop is completed - thus, outside ofloop)Â Â Â Check (usingsearching) if match was found, todetermine the return value
- (At some point) Print formatted book details (iffound) or error (if not found)
- Add method to remove ONLY the FIRST book inbooks matchingcallNumber:
publicvoid removeGenreBookWithCallNumber(String callNumber)Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
- MUST 1st usefindGenreBookWithCallNumber( ) to findindex of callNumber
- if bookIndexValid( ) of thereturned index, then perform removal using the index and then printformatted output “Removing: <bookdetails>â€
- else print \"NO book with call number:â€
HINT: MUSTNOT use any type of loops at all
- Add method to remove ALL items inbooks matching a particularauthor
publicvoid removeAllGenreBooksByAuthor(Stringauthor)Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
- MUST use Iteratorand while loop to search through thebooks ArrayList
- Remove book if author EXACTLY matches(without case-sensitivity)
- MUST print book details for EACHremoved or 1 error output (if not found)
HINT:MUST use .remove methodfrom Iterator to ensure properremovals
- Add method void listAllGenreBooks( )to print out ALL items in books
- if books ArrayList is empty, printâ€NO books to printâ€
- else print heading “BOOKS:†and use for-each to print eachBook’s book details with leading “†on its own line
- Add void listGenreBooksByAuthor(Stringauthor) to print ALL authormatches
- Always print heading: “ BOOKS BYAUTHOR :â€
- Use for-each and String.equalsIgnoreCase() to check every book inbooks to findauthor matches to print their bookdetails with leading “ â€
(Only after ENTIRE search loop is completed - thus, outside ofloop)   Check if NO match found, then printâ€NO books by author: â€
- Create “New Class…†Library for agroup of genres and a book of the week
- Import all necessary Java package library classes
- Declare 2 fields for each library:
- field named bookOfTheWeek of typeBook
- field named genres of typeArrayList of Genre
- Write a constructor with header public Library() to initialize both fields
HINT: Includeinstantiation of a new genres ArrayListobject AND initialize bookOfTheWeek toeither null or use (optional)pickBookOfTheWeek( )
- Add method int getNumberOfTotalBooksto return the TOTAL number of books in the ENTIRE library (includeALL genres) or 0 if there are NO books
HINT:MUST use for-each loop and call togetNumberOfGenreBooks( )
- Overload method addGenre (with thefollowing headers) to add a new genre to the library using theArrayList .add method:
- public void addGenre(Genregenre)Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
- public void addGenre(StringgenreName)
HINT:MUST create and use a newGenre anonymous object in #2.
- Add method void removeGenre(StringgenreName) to remove the FIRST genre ONLY inArrayList genres matching thegenreName searchparameter                                Â
HINT:MUST use Iterator to helpget the genre toremove it and also include any formattedoutput detailing the removal or an error message (if not found)
- Add method void listAllGenres( ) toprint out ALL genreNames ingenres with a heading format:“THE GENRE NAMES:†(or error msg if NOgenres)
HINT: Use for-each and print formatted genre info withleading spaces “    â€
- Add method void listAllLibraryBooks() to print out ALL books inALL genres in the ENTIRElibrary                                              Â
HINT: First check usinggetNumberOfTotalBooks that the libraryhas books and print error message if there are NO books in theentire library
HINT:MUST use Iterator andlistAllGenreBooks to help print the booksfor each genre (Yes, I know it’s possible w/o an Iterator, BUT youMUST use it !!!)
Add method void printBookOfTheWeek( )to print out the details of thebookOfTheWeek or an error stating thatâ€There is NO Book of the Weekâ€HINT:MUST have a heading and usegetBookDetails( ) to print thedetails
- Add method void pickBookOfTheWeek( )to randomly pick a Book in the entirelibrary from any of thegenres as thebookOfTheWeek                                              Â
HINT: First check that Library hasbooks to chose from, then use Random to pick arandom Genre. Then, MUST check the chosenGenre has books before picking a randomBook from the randomly selected genre. Ifthere are NO books in the selected genre, then repeat the loop bytrying another genre. Remember to callgetGenreBooks andprintBookOfTheWeek (as needed)