Library Management System Project In Java With Source Code Official

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"));

// Book operations public void addBook(String title, String author, String genre, int quantity) Book book = new Book(nextBookId++, title, author, genre, quantity); books.add(book); System.out.println("Book added successfully! ID: " + book.getId());

book.setQuantity(book.getQuantity() - 1); issuedBooks.put(bookId, memberId); System.out.println("Book issued successfully to " + member.getName()); Library Management System Project In Java With Source Code

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

public Book(int id, String title, String author, String genre, int quantity) this.id = id; this.title = title; this.author = author; this.genre = genre; this.quantity = quantity; public void showIssuedBooks() if (issuedBooks

public Member findMemberById(int id) return members.stream().filter(m -> m.getMemberId() == id).findFirst().orElse(null);

if (book == null) System.out.println("Book not found."); return; if (member == null) System.out.println("Member not found."); return; if (book.getQuantity() <= 0) System.out.println("Book out of stock."); return; if (issuedBooks.containsKey(bookId)) System.out.println("Book already issued to another member. Please wait for return."); return; Please wait for return

while (true) System.out.println("\n===== LIBRARY MANAGEMENT SYSTEM ====="); System.out.println("1. Add Book"); System.out.println("2. View All Books"); System.out.println("3. Search Book by Title"); System.out.println("4. Register Member"); System.out.println("5. View All Members"); System.out.println("6. Issue Book"); System.out.println("7. Return Book"); System.out.println("8. View Issued Books"); System.out.println("9. Exit"); System.out.print("Enter choice: ");