// Name : Matthew Reeves // This is a program to create an unsorted book list //creates the UnsortedBookList class public class UnsortedBookList { //sets variables for the class private final int DEFCAP=10; private Book List[]; private int numElements; private int origCap; //default constructor public UnsortedBookList() { List=new Book[DEFCAP]; origCap=DEFCAP; numElements=0; } //constructor passed user inputted size variable throws //size out of range exception if size out of range public UnsortedBookList(int size) throws Exception { if (size>0) { List=new Book[size]; origCap=size; numElements=0; } else { throw new Exception ("Error list size out of range"); } } //method to add items to the list. Method enlarges array if needed public void addItem(Book theBook) { if (List.length==numElements) { enlarge(); } List[numElements]=theBook; numElements++; } //removes item if item is present in list public boolean removeItem(Book theBook) { int location=find(theBook); if (location==-1) { return false; } else { List[location]=List[numElements-1]; numElements--; return true; } } //allows user to search list for a specific book public boolean findItem(Book theBook) { if (find(theBook)==-1) { return false; } else { return true; } } //checks if the list is empty public boolean isEmpty() { if (numElements<=0) { return true; } else { return false; } } //checks and returns numElements public int lengthIs() { return numElements; } //builds and returns a formatted string to print the list to screen public String toString() { if (numElements<=0) { return String.format("***List is Empty***"); } else { String tempString=""; for(int count=0;countorigCap) { Book newList[]; newList=new Book[origCap]; List=newList; } } //allows the program to dynamically expand the size of the list array private void enlarge() { Book larger[]; larger=new Book[List.length+origCap]; for (int count=0; count