package class1_3_Interfaces_start;// Dr. Yoder. MSOE. 02 December 2016 import java.util.ArrayList; /** * This class represents a home (paper hardcopy) library collection */ public class Library { private ArrayList books = new ArrayList<>(); /** * Pull the book off of the shelf by the specific author. * @param author the full name of the person who wrote the book. * @return the requested book (or null if not found! * ... wish there was a better way to handle this....) */ public Book findByAuthor(String author) { int i = 0; Book found; while(i < books.size() && books.get(i).getAuthor().equals(author)) { i++; } if(i == books.size()) { found = null; } else { found = books.get(i); } return found; } /** * Add a set of books to the library. * Null references are skipped and not added to the library. * (Is there a better way to handle this?) * @param books the books to be added */ public void addBooks(ArrayList books) { if(books != null) { for (Book book : books) { if (book != null) { this.books.add(book); } } } } }