You are on page 1of 1

Core Java Assignment - Library Management System

Description:

You are tasked with implementing a Library Management System in Java. The system should allow users to add
books to the library, search for books, borrow books, and return books. Additionally, it should incorporate Java
8 features, handle exceptions, and utilize collections.

Requirements:

1. Create a Book class with the following attributes:


● title (String)
● author (String)
● isbn (String)
● Genre (String)
● available (boolean)

2. Create a Library class that manages the books. It should have the following methods:
● addBook(Book book): Adds a book to the library.
● searchByTitle(String title): Searches for books by title and prints the details of matching
books.
● searchByAuthor(String author): Searches for books by author and prints the details of
matching books.
● searchByGenre(String Genre): Searches for books by Grnre and prints the details of
matching books.
● IssueBook(String isbn) throws BookUnavailableException: Marks a book as borrowed by
setting its available attribute to false.
● returnBook(String isbn) throws BookNotFoundException: Marks a borrowed book as returned
by setting its available attribute to true.
● displayAllBooks(): Prints the details of all the books in the library.
● displayAvailableBooks(): Prints the details of available books in the library.
● addUser(): add the user to borrow the book.
● Issuedtouser(): prints the details of all the books issued to the user.

3. Implement the BookUnavailableException class that extends Exception. This exception should be thrown
when a user tries to borrow an unavailable book.

4. Implement the BookNotFoundException class that extends Exception. This exception should be thrown
when a user tries to return a book that is not found in the library.

5. Utilize Java 8 features wherever applicable. For example, use lambda expressions or method references
to perform operations on collections.

Instructions:

1. Create the necessary Java classes and ensure they are properly organized.
2. Implement the methods in the Library class according to the provided requirements.
3. Test your implementation by creating a main method and performing the following operations:
● Add a books to the library
● Display all the books in the library.
● Search for books by title, genre and author.
● Issue a book and handle any exceptions that may occur.
● Return a book and handle any exceptions that may occur.
● Display all the books in the library after the operations.
● Add muliple users in the library to take the book.
● Issue the book with timestamp only for 90days
● Add fine into user’s Library card if book has been issued for more than 90 days
● Calculate the fine at the rate 2% of cost of the book per day
● Display the library card of each user.

Note: You are free to add additional methods or classes as needed to complete the assignment.

You might also like