Question: I'm trying to figure out why my code is not compiling. Thanks. import java.util.ArrayList; import java.util.Date; public class Library { public static final char AUTHOR_SEARCH

I'm trying to figure out why my code is not compiling. Thanks.

import java.util.ArrayList; import java.util.Date; public class Library { public static final char AUTHOR_SEARCH = 'A'; public static final char OVERDUE_SEARCH = 'O'; public static final char PATRON_SEARCH = 'P'; public static final char TITLE_SEARCH = 'T'; private Book[] books; private Patron[] patrons; public Library(Book[] books, Patron[] patrons) { this.books = books; this.patrons = patrons; } public Book[] getBooks() { return books; } public void setBooks(Book[] books) { this.books = books; } public Patron[] getPatrons() { return patrons; } public void setPatrons(Patron[] patrons) { this.patrons = patrons; } public boolean checkin(Book book) { boolean found = false; int index = -1; for(int i=0;i 0) { return interval*0.5; } else { return 0.0; } } public Book[] searchBook(Object key, char type) { ArrayList result = new ArrayList<>(); switch(type) { case TITLE_SEARCH: String title = (String) key; for(Book b : books) { if(b.getTitle().equals(title)) { result.add(b); } } break; case AUTHOR_SEARCH: String author = (String) key; for(Book b : books) { if(b.getAuthor().equals(author)) { result.add(b); } } break; case PATRON_SEARCH: for(Book b : books) { if(b.getPatron().equals(key)) { result.add(b); } } break; case OVERDUE_SEARCH: Date overdue = (Date)key; for(Book b : books) { if(DateUtils.interval(overdue, b.getDue()) == 0) { result.add(b); } } break; default: break; } return result.toArray(new Book[0]); } }

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!