Package com.miniproject.two
Class Library
java.lang.Object
com.miniproject.two.Library
Library Management System - Library Class
This class represents a Library that contains a collection of books and
provides
various methods to manage them. The Library allows adding, removing,
searching,
borrowing, and returning books. It also supports displaying all books in the
collection.
The Library class includes methods for:
- Adding a new book with details like title, author, ISBN, genre, publication format, and more.
- Removing books based on a search term.
- Searching for books using a search term.
- Displaying all books in the library.
- Borrowing a book by ISBN and recording the borrower's name.
- Returning a borrowed book by ISBN.
- Ensuring the ISBN is valid.
- Handling availability status updates when borrowing and returning books.
- Since:
- 2024-06-25
- Version:
- 1.0
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addBook
(String title, String author, String isbn, String genre, String subgenre, String nationality, String publicationFormat, int publishedYear, String publisherName, String deweyDecimal, boolean isAvailable, String borrowedByUserName) Adds a new book to the library.boolean
borrowBook
(String ISBN, String borrowerName) Borrows a book from the library based on the provided ISBN and borrower name.getBooks()
removeBook
(String searchTerm) Removes books from the library based on the provided search term.removeBookById
(int bookId) Removes a book from the library based on the provided book ID.boolean
returnBook
(String ISBN) Returns a book to the library based on the provided ISBN.searchBooks
(String searchTerm) Searches for books in the library based on the provided search term.showBookById
(int bookId) Displays books in the library based on the provided book ID.Displays all the books in the library.void
updateBook
(int bookId, String title, String author, String isbn, String genre, String subgenre, String nationality, String publicationFormat, int publishedYear, String publisherName, String deweyDecimal, boolean isAvailable, String borrowedByUserName) Updates the details of a book in the library.
-
Constructor Details
-
Library
public Library()
-
-
Method Details
-
getBooks
-
addBook
public void addBook(String title, String author, String isbn, String genre, String subgenre, String nationality, String publicationFormat, int publishedYear, String publisherName, String deweyDecimal, boolean isAvailable, String borrowedByUserName) Adds a new book to the library.- Parameters:
title
- the title of the bookauthor
- the author of the bookisbn
- the ISBN of the bookgenre
- the genre of the booksubgenre
- the subgenre of the booknationality
- the nationality of the bookpublicationFormat
- the publication format of the bookpublishedYear
- the year the book was publishedpublisherName
- the name of the publisherdeweyDecimal
- the Dewey decimal classification of the bookisAvailable
- whether the book is available or notborrowedByUserName
- the username of the user who borrowed the book
-
updateBook
public void updateBook(int bookId, String title, String author, String isbn, String genre, String subgenre, String nationality, String publicationFormat, int publishedYear, String publisherName, String deweyDecimal, boolean isAvailable, String borrowedByUserName) Updates the details of a book in the library.- Parameters:
bookId
- the ID of the book to be updatedtitle
- the new title of the bookauthor
- the new author of the bookisbn
- the new ISBN of the bookgenre
- the new genre of the booksubgenre
- the new subgenre of the booknationality
- the new nationality of the bookpublicationFormat
- the new publication format of the bookpublishedYear
- the new year the book was publishedpublisherName
- the new name of the publisherdeweyDecimal
- the new Dewey decimal classification of the bookisAvailable
- the new availability status of the bookborrowedByUserName
- the new username of the user who borrowed the book
-
removeBook
Removes books from the library based on the provided search term.- Parameters:
searchTerm
- the term used for searching books- Returns:
- a list of books that match the search criteria
-
removeBookById
Removes a book from the library based on the provided book ID.- Parameters:
bookId
- the ID of the book to be removed- Returns:
- a list of books that match the provided book ID
-
searchBooks
Searches for books in the library based on the provided search term.- Parameters:
searchTerm
- the term used for searching books- Returns:
- a list of books that match the search criteria
-
showBooks
Displays all the books in the library. This function checks if the list of books is empty. If it is, it prints a message indicating that no books were found. If the list is not empty, it prints a message indicating that all books are being shown, followed by the title, author, ISBN, publication year, and genre of each book in the list.- Returns:
- the list of all books in the library
-
showBookById
Displays books in the library based on the provided book ID.- Parameters:
bookId
- the ID of the book to be displayed- Returns:
- a list of books that match the provided book ID
-
borrowBook
Borrows a book from the library based on the provided ISBN and borrower name.- Parameters:
ISBN
- the ISBN of the book to be borrowedborrowerName
- the name of the borrower- Returns:
- true if the book was successfully borrowed, false otherwise
-
returnBook
Returns a book to the library based on the provided ISBN.- Parameters:
ISBN
- the ISBN of the book to be returned- Returns:
- true if the book was successfully returned, false otherwise
-