Library Management System Project In Java With Source Code Apr 2026

public void returnBook(int bookId) if (!issuedBooks.containsKey(bookId)) System.out.println("This book was not issued."); return;

public void showIssuedBooks() if (issuedBooks.isEmpty()) System.out.println("No books currently issued."); return; System.out.println("\nIssued Books (Book ID -> Member ID):"); for (Map.Entry<Integer, Integer> entry : issuedBooks.entrySet()) Issued to: " + (m != null ? m.getName() : "Unknown"));

private LibraryService libraryService;

public void showAllMembers() Name package service; import model.Book; import model.Member; import java.util.HashMap; import java.util.Map; Library Management System Project In Java With Source Code

import service.LibraryService; import service.TransactionService; import java.util.List; import java.util.Scanner; import model.Book; public class Main public static void main(String[] args) LibraryService libraryService = new LibraryService(); TransactionService transactionService = new TransactionService(libraryService); Scanner scanner = new Scanner(System.in);

public List<Book> searchBookByTitle(String title) return books.stream() .filter(b -> b.getTitle().toLowerCase().contains(title.toLowerCase())) .collect(Collectors.toList());

public TransactionService(LibraryService libraryService) this.libraryService = libraryService; public void returnBook(int bookId) if (

@Override public String toString() return id + " package model; public class Member private int memberId; private String name; private String email; private String phone;

public void issueBook(int bookId, int memberId) Book book = libraryService.findBookById(bookId); Member member = libraryService.findMemberById(memberId);

@Override public String toString() " + phone; System.out.println("\nIssued Books (Book ID -&gt

Share it with your fellow developers and leave a comment below!

public Member(int memberId, String name, String email, String phone) this.memberId = memberId; this.name = name; this.email = email; this.phone = phone;

// Getters and Setters public int getId() return id; public String getTitle() return title; public String getAuthor() return author; public String getGenre() return genre; public int getQuantity() return quantity; public void setQuantity(int quantity) this.quantity = quantity;

Book book = libraryService.findBookById(bookId); if (book != null) book.setQuantity(book.getQuantity() + 1); issuedBooks.remove(bookId); System.out.println("Book returned successfully.");