0% found this document useful (0 votes)
34 views1 page

Java Library Management System Project

The document describes a core Java assignment to create a library management system. It involves developing classes for a Book and Library and implementing methods in the Library class to add, search, borrow, and return books. Exceptions must be handled for unavailable or not found books. Java 8 features like lambda expressions should be used. The requirements include testing the classes by adding books, issuing and returning books, and handling exceptions. Users should also be added and books issued with timestamps and fines calculated for overdue returns.

Uploaded by

Abhishek Singh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views1 page

Java Library Management System Project

The document describes a core Java assignment to create a library management system. It involves developing classes for a Book and Library and implementing methods in the Library class to add, search, borrow, and return books. Exceptions must be handled for unavailable or not found books. Java 8 features like lambda expressions should be used. The requirements include testing the classes by adding books, issuing and returning books, and handling exceptions. Users should also be added and books issued with timestamps and fines calculated for overdue returns.

Uploaded by

Abhishek Singh
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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.

Common questions

Powered by AI

Lambda expressions and method references simplify operations on book collections by reducing verbosity and enabling more concise code. They allow direct representation of behavior as an argument, making operations like filtering, sorting, and mapping more intuitive and efficient. For instance, a lambda expression can succinctly specify a criterion for filtering available books, improving both performance and readability compared to traditional loops and conditional logic .

Java 8 features can be effectively used in implementing the search functionalities through lambda expressions and method references. These features can streamline operations on collections such as filtering books based on title, author, or genre. For instance, the Stream API can be used to filter and collect books that match the search criteria succinctly, improving readability and reducing boilerplate code .

Challenges in implementing the 'addUser' method can include ensuring unique user identities, managing user data securely, and handling concurrent updates. These can be addressed by integrating validation checks for unique identification (such as user ID) and implementing secure storage and access protocols for personal data. Concurrency issues can be mitigated through synchronization or transactional mechanisms to maintain data consistency when multiple users are added or updated simultaneously .

In the Library Management System, book borrowing is directly linked to user management and fine calculations. When a book is borrowed, a user must be associated with the borrowing action, which is recorded on their library card. The system issues books with a timestamp, allowing borrowing only for 90 days. If a book is not returned within this period, a fine is calculated at a rate of 2% of the book's cost per overdue day. This integrated approach ensures accountability and timely return of books while managing each user's borrowing activity .

The 'displayAvailableBooks' method is crucial as it allows users to quickly identify which books can be borrowed, enhancing user satisfaction and system efficiency. To ensure optimal user experience, this method should filter and display books with an 'available' status efficiently, possibly using Java 8's Stream API for filtering. It should provide clear output, such as book titles, authors, and availability status, to facilitate user decision-making .

Implementing a borrowing limit of 90 days along with a fine policy based on overdue days improves operational efficiency by incentivizing timely return of books, thus maximizing book availability and circulation. It encourages users to adhere to borrowing terms, reducing incidences of books being misplaced or unaccounted for over extended periods. However, it also requires the system to efficiently track borrowing dates and calculate fines accurately, which might add complexity but increases accountability and management efficiency .

The Library Management System handles exceptions related to book availability using custom exception classes: BookUnavailableException and BookNotFoundException. The BookUnavailableException is thrown when a user attempts to issue a book that is not available, i.e., its 'available' attribute is set to false. The BookNotFoundException is thrown when a user tries to return a book using an ISBN that does not match any book in the library's collection. This ensures that only available books can be borrowed, and only existent borrowed books can be returned .

Using a separate Book class with well-defined attributes such as title, author, isbn, genre, and available status enhances modularity and clarity of data representation. It allows the system to manage each book's state independently, facilitating operations like searching, issuing, and returning books. Moreover, this encapsulated design promotes cleaner and more maintainable code by adhering to the object-oriented principle of encapsulation .

Including a user library card feature offers several benefits, such as improved tracking of user borrowing history, accountability, and streamlined fine calculations. It allows the library to maintain detailed user records, enhance personalized services, and manage overdue fines effectively. However, it may also introduce challenges in data privacy, requiring robust measures to secure personal data and prevent unauthorized access. Furthermore, the complexity of implementing accurate and fair fine calculations may increase system overhead .

Collections enhance the functionality of the Library class by providing flexible and efficient ways to store, retrieve, and manipulate book data. Types of collections such as Lists or Sets can be used to store book objects, allowing easy addition, removal, and iteration. Lists would be suitable for ordered sequences of books, while Sets can prevent duplicate entries, ensuring each ISBN is unique. Moreover, leveraging collections supports operations like searching and filtering through Java 8's Stream API .

You might also like