COP3804 Spring, 2015 Assignment #2 – Library System phase II Last updated 03/03/2015 02:00 pm For assignment number 2, we are going to enhance our Library System to read and parse data from an input file. We are also adding some data validation, exception handling, as well as, a new utility class called LibraryUtility. Below is the list of modifications we are making to the project (feel free to use the solution I posted in moodle for phase 1). Member class: Modification 1: In the constructor that has 5 parameters, as well as in the setMemberID method, if the id parameter is less than or equal to zero, throw an IllegalArgumentException. Code provided below: // if the id parameter is negative or equal to 0, throw an exception. if( id > 0 ) memberID = id; else throw new IllegalArgumentException("Member ID must be a positive number."); Modification 2: Update the javadoc comments to include the @exception tag for both, the constructor and the setMemberID method. Item class: Modification 1: In the constructor that has 5 parameters, as well as in the setItemID method, if the id parameter is less than or equal to zero, throw an IllegalArgumentException. The message for the exception would be: "Item ID must be a positive number." Modification 2: Update the javadoc comments to include the @exception tag for both, the constructor and the setItemID method. PrintedBook class: Modification 1: In the calculateFee and calculateFine methods, if the numDays parameter is less than or equal to zero, throw an IllegalArgumentException. The message for the exception would be: "The number of days must be a positive number." Modification 2: Update the javadoc comments to include the @exception tag for both methods. DVD class: Modification 1: In the calculateFee and calculateFine methods, if the numDays parameter is less than or equal to zero, throw an IllegalArgumentException. The message for the exception would be: "The number of days must be a positive number." Modification 2: Update the javadoc comments to include the @exception tag for both methods. LibraryUtility class: Add a new class to the project called LibraryUtility, which is a utility class used as a repository of static methods that can be used by all the other classes in the project. We will not create objects of this class so we need no constructors, no instance variables or instance methods. Please see the class members below: Private Static Variables: lastAssignedMemberID of type int lastAssignedItemID of type int Note: Provide the corresponding getter and setter methods for each variable. Public Static Methods: getNextMemberID – This method increments the value stored in the lastAssignedMemberID static variable by one and returns the new value. getNextItemID – This method increments the value stored in the lastAssignedItemID static variable by one and returns the new value. findMember – This method has two parameters, an ArrayList of Member elements, and a Member object to search for in the list. This method returns the element in the list found to be equal to the parameter. Otherwise, it returns null. Note: make sure to use the equals method in the Member class. The following is the method signature: public static Member findMember(ArrayList<Member> memberList, Member member) findItem – This method has two parameters, an ArrayList of Item elements, and an Item object to search for in the list. This method returns the element in the list found to be equal to the parameter. Otherwise, it returns null. Note: make sure to use the equals method in the Item class. findRequest – This method has two parameters, an ArrayList of Request elements, and a Request object to search for in the list. This method returns the element in the list found to be equal to the parameter. Otherwise, it returns null. Note: make sure to use the equals method in the Request class. LibrarySystem_Phase2 class: We are adding the functionality to load Members and Items from a data file. Note: theLibrary is a class variable was added to this class. The processLineOfData method should add Member and Item objects to its memberList and itemList instance variables. Modification 1: Write a method called processLineOfData that has a String parameter and the return type is void. The parameter represents one line of data in the file, which could be data for a Member, PrintedBook, ElectronicBook, AudioBook, or DVD. See the note below for the expected format for each line. I’m providing you with an algorithm below: public static void processLineOfData(String line) throws Exception { // Split the line parameter on the comma. // Get the first field to determine the record type: // M -> Member // P -> PrintedBook // E -> ElectronicBook // A -> AudioBook // D -> DVD // // // // // // // // If the line has Member data, check if the member already exists in the library’s memberList variable (use the findMember method of the LibraryUtility class. If it exists, don’t do anything. If it doesn’t exist, get the next member id number (use the getNextMemberID method of the LibraryUtility class), update the memberID field of the Member object, and add it to the library’s memberList variable (use the addMember method of Library class). // // // // // // // If the line has PrintedBook data, check if the item already exists in the library’s itemList variable (use the findItem method of the LibraryUtility class. If it exists, don’t do anything. If it doesn’t exist, get the next item id number (use the getNextItemID method of the LibraryUtility class), update the itemID field of the Item object, and add it to the library’s itemList variable (use the addItem // method of Library class. // If the line has ElectronicBook, AudioBook, or DVD data, process it // similarly as the PrintedBook case. // If the line is none of the above types, throw an // Exception object with the message “Bad record”. } Data Formats in the input data file The following is the expected format for each type of data in the input file: Member M,first,last,phone PrintedBook P,title,genre,audience,available,author,isbn,cover ElectronicBook E,title,genre,audience,available,author,isbn,type AudioBook A,title,genre,audience,available,author,isbn,duration,extra charge DVD D,title,genre,audience,available,video number,duration,closed captions Group Member Responsibilities: Group Member 1 Group Member 2 Group Member 3 Group Member 4 Member class modifications. Declare the LibraryUtility class including variable declarations, getter, and setter methods (include javadoc comments for the methods). In the LibraryUtility class, write the findItem method (include javadoc comments). In the processLineOfData method of the LibrarySystem_Phase2 class, split the line parameter, and setup an if or switch statement to look at the first character. Item class modifications. In the LibraryUtility class, write the getNextMemberID and findRequest methods (include javadoc comments). Write the code in the processLineOfData method of the LibrarySystem_Phase2 class, to process the data for a Member. PrintedBook class modifications. In the LibraryUtility class, write the getNextItemID method (include javadoc comments). Write the code in the processLineOfData method of the LibrarySystem_Phase2 class, to process the data for a PrintedBook and an AudioBook. DVD class modifications. In the LibraryUtility class, write the findMember method (include javadoc comments). Write the code in the processLineOfData method of the LibrarySystem_Phase2 class, to process the data for an ElectronicBook and a DVD.