Library Management System Project In Java With Source Code ⚡ Trusted

public class TransactionService private Map<Integer, Integer> issuedBooks = new HashMap<>(); // bookId -> memberId

public TransactionService(LibraryService libraryService) this.libraryService = libraryService; Library Management System Project In Java With Source Code

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")); public class TransactionService private Map&lt

public Book findBookById(int id) return books.stream().filter(b -> b.getId() == id).findFirst().orElse(null); issuedBooks = new HashMap&lt

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

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

Ir para cima