Question: Write a class called LibrarySystem having the following data members: booksList: list of books LinkedList object, each element is of type Book, membersList: booksListSize: list
Write a class called LibrarySystem having the following data members: booksList: list of books LinkedList object, each element is of type Book, membersList: booksListSize: list of members LinkedList object, each element is of type LibMember, actual number of objects of type Book in booksList, membersListSize: actual number of objects of type LibMember in membersList. Include following methods in this class: i Constructor without any parameters. Create booksList and membersList as empty linked lists and initialize booksListSize and membersListSize to ii addBook: inserts a new Bookobject at the end of the booksList. Object of type Book is passed as parameter. If the object already exists in the list, then do not add the object and return false, else return true after successfully adding the Book. iii deleteBook: deletes a Book object from booksList. Accession number of the Book is passed as parameter. If the Book is issued to a member or the object is not found in the booksList, then the Book cannot be deleted and the method returns false, else the method returns true, after successfully deleting the object. iv addMember: inserts a new LibMember object at the end of the membersList. Object of type LibMember is passed as parameter. If the object already exists in the list, then do not add the object and return false, else return true after successfully adding the member. v deleteMember: deletes a LibMember object from membersList. CPR number of the LibMember is passed as parameter. If any Book is issued to the member or the object is not found in the membersList, then the member cannot be deleted and the method returns false, else the method returns true, after successfully deleting the object. vi searchBook: searches the booksList by accessionNum, passed as parameter. If the object is found, it returns its location in the booksList, else returns vii searchMember: searches the membersList by cprNum, passed as parameter. If the object is found, it returns its location in the membersList, else returns viii isEmptyBooksList: returns true if the booksList is empty, else returns false. ix isEmptyMembersList: returns true if the membersList is empty, else returns false. x sizeBooksList: returns instance variable booksListSize. xi sizeMembersList: returns instance variable membersListSize. xii issueBook: accepts accession number of a Book as the first parameter and the CPR number of the member as the second parameter. The Book can be issued to a member only if: a The Book exists in the booksList, c The Book is not issued to any member, bThe member exists in the membersList, d The member has less than books issued to himher If the book can be issued to a member, then add the Book object in the booksIssued array for the member, increment numBooksIssuedby for the member and also make issuedTo instance variable of the Book object reference to the member and return true. If the Book cannot be issued then return false. Note that there will be cross referencing between the book and the member. xiii returnBook: accepts accession number of a Book as the parameter. The Book can be returned only if: a The Book exists in the Books list, b The Book is issued to a member. If the Book can be returned, then delete it from booksIssued array for the member, decrement numBooksIssued by one for the member and also make issuedTo instance variable of the Book object to null and return true. If the Book cannot be returned, then return false. xiv printBooksIssued: accepts CPR number of a member as a parameter and prints details of all the books issued to the member. xv isBookIssued: accepts accession number of the Book as parameter. It returns true if the Book object exists in the bookList and is issued to a member, else returns false. D Write a class called LibraryMain having only main method to test all the functionalities of class LibrarySystem. Write main as a menu driven program using switch statement. NOTE: For booksList and membersList, use LinkedList builtin class of java. It is a doubly linked list with ListIterator.Write detailed comments for each class and method. Write comments using Javadoc.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
