Java Pbl PDF
Java Pbl PDF
INTRODUCTION
The Library Management System is a Java application designed to efficiently manage
the inventory of a library. It provides a user-friendly interface for librarians and
patrons to perform various tasks related to book management. This system offers
functionalities like adding new books to the library, updating book information,
checking in/out books, and searching for books based on titles, authors, or genres.
KEY FEATURES :
1. Book Management: Librarians can easily add new books to the library
inventory. Each book is associated with its title, author, and genre information.
2. Inventory Display: The system allows users to display the complete inventory
of the library, showing details such as book title, author, genre, and availability
status (checked in or checked out).
3. Search Functionality: Users can search for books by entering keywords
related to titles, authors, or genres. The system then provides search results
matching the entered query, facilitating easy access to desired books.
4. Check In/Out: Patrons can check out books they wish to borrow, marking
them as unavailable for other patrons. Likewise, they can check in books they
have borrowed, making them available for other users.
5. User-Friendly Interface: The system features a simple and intuitive interface,
making it easy for both librarians and patrons to navigate and perform
necessary actions.
Overall, the Library Management System streamlines the book management process,
enhances accessibility to library resources, and improves the overall efficiency of
library operations. Whether it's adding new books, updating information, or
facilitating book transactions, this system provides a robust solution for effective
library management.
CODE
import java.util.*;
class Book {
private String title;
private String author;
private String genre;
private boolean checkedOut;
class Library {
private ArrayList<Book> books;
public Library() {
books = new ArrayList<>();
}
switch (choice) {
case 1:
library.displayBooks();
break;
case 2:
System.out.print("Enter title, author, or genre to search: ");
String query = scanner.nextLine();
library.searchBook(query);
break;
case 3:
System.out.println("Enter book details:");
System.out.print("Title: ");
String title = scanner.nextLine();
System.out.print("Author: ");
String author = scanner.nextLine();
System.out.print("Genre: ");
String genre = scanner.nextLine();
library.addBook(new Book(title, author, genre));
System.out.println("Book added successfully.");
break;
case 4:
System.out.print("Enter the title of the book to check out: ");
String checkOutTitle = scanner.nextLine();
library.checkOutBook(checkOutTitle);
break;
case 5:
System.out.print("Enter the title of the book to check in: ");
String checkInTitle = scanner.nextLine();
library.checkInBook(checkInTitle);
break;
case 6:
exit = true;
System.out.println("Thank you for using Library Management System.");
break;
default:
System.out.println("Invalid choice. Please enter a number between 1 and 6.");
}
}
scanner.close();
}
}
In this code, two classes are defined: Book and Library. The Book class represents a
book with its properties (title, author, genre, checked-out status) and getters/setters.
The Library class manages the book inventory and provides methods for adding
books, updating information, checking in/out books, and searching based on
different criteria.