Harsh
Harsh
Book inventories, lending information, member activity management, all around issues for
libraries. We reduce these chores with an Object-oriented Java-based Library Management
System. The program creates:
Librarians view, add, subtract books to control book availability.
Members also track borrowed items in addition to lending and return records.
Simple records of borrowing for good financial control.
2. UML Diagram
2.1 UML
2.2. Character definition of design
3. Code Implementation
import java.util.ArrayList;
import java.util.List;
// Book Class
class Book {
this.title = title;
this.author = author;
this.copiesAvailable = copiesAvailable;
return title;
return "Title: " + title + ", Author: " + author + ", Copies: " + copiesAvailable;
if (copiesAvailable > 0) {
copiesAvailable--;
} else {
// Member Class
class Member {
this.name = name;
if (book != null) {
book.borrowCopy();
borrowedBooks.add(book);
} else {
}
public void returnBook(Book book) {
if (borrowedBooks.contains(book)) {
book.returnCopy();
borrowedBooks.remove(book);
} else {
System.out.println(book.getDetails());
// Librarian Class
class Librarian {
System.out.println("Library Inventory:");
for (Book book : books) {
System.out.println(book.getDetails());
books.add(book);
if (books.remove(book)) {
} else {
// Main Class
librarian.addBook(book1, libraryBooks);
librarian.addBook(book2, libraryBooks);
// Viewing books
librarian.viewBooks(libraryBooks);
// Member actions
member.borrowBook(book1);
member.viewBorrowedBooks();
member.returnBook(book1);
librarian.viewBooks(libraryBooks);
}
3.2. Code Explanation
1. Book Class:
2. Member Class:
3. Librarian Class:
o Provides methods for adding, removing, and viewing books in the library's
inventory.
4. Main Class: