A console & GUI-based Library Management System built in Java as part of the CMP5332 Object-Oriented Programming module at BCU (Birmingham City University) — Group D7.
- Book Management — Add, list, view details, and soft-delete books
- Patron Management — Add, list, view details, and soft-delete patrons
- Borrowing System — Issue, renew, and return books with due-date tracking
- Loan Tracking — Tracks who borrowed which book and when it is due
- Data Persistence — Books, patrons, and loans are saved to/loaded from text files
- Dual Interface — Interactive command-line (CLI) and a full Swing-based GUI
- Unit Tests — JUnit 5 + Mockito test suite for
BookandPatronmodels
src/bcu/D7/librarysystem/
├── main/
│ ├── Main.java # Entry point (CLI REPL)
│ ├── CommandParser.java # Parses user input into Command objects
│ └── LibraryException.java # Custom exception class
├── model/
│ ├── Book.java # Book entity with soft-delete & loan status
│ ├── Patron.java # Patron entity (max 2 books per patron)
│ ├── Loan.java # Loan entity (patron + book + dates)
│ └── Library.java # Central library: holds books & patrons
├── commands/
│ ├── Command.java # Command interface + help message
│ ├── AddBook.java # Add a new book
│ ├── AddPatron.java # Add a new patron
│ ├── BorrowBook.java # Borrow a book
│ ├── RenewBook.java # Renew a borrowed book
│ ├── ReturnBook.java # Return a borrowed book
│ ├── DeleteBook.java # Soft-delete a book
│ ├── DeletePatron.java # Soft-delete a patron
│ ├── ShowBook.java # Show detailed book info
│ ├── ShowPatron.java # Show detailed patron info
│ ├── ListBooks.java # List all books
│ ├── ListPatrons.java # List all patrons
│ ├── LoadGUI.java # Launch the Swing GUI
│ └── Help.java # Display available commands
├── data/
│ ├── DataManager.java # Interface for data load/store
│ ├── LibraryData.java # Orchestrates all data managers
│ ├── BookDataManager.java # Reads/writes books.txt
│ ├── PatronDataManager.java # Reads/writes patrons.txt
│ └── LoanDataManager.java # Reads/writes loans.txt
├── gui/
│ ├── MainWindow.java # Main Swing window with menus
│ ├── AddBookWindow.java # Dialog to add a book
│ ├── AddPatronWindow.java # Dialog to add a patron
│ ├── IssueBookWindow.java # Dialog to issue a book
│ └── ReturnBookWindow.java # Dialog to return a book
└── test/
├── BookTest.java # Unit tests for Book (JUnit 5 + Mockito)
└── PatronTest.java # Unit tests for Patron (JUnit 5 + Mockito)
# Compile (from the project root)
javac -d out src/bcu/D7/librarysystem/**/*.java
# Run
java -cp out bcu.D7.librarysystem.main.MainFrom the CLI, type loadgui after launching, or run the MainWindow directly.
| Command | Description |
|---|---|
addbook |
Add a new book |
addpatron |
Add a new patron |
listbooks |
List all books |
listpatrons |
List all patrons |
showbook <id> |
Show detailed book info |
showpatron <id> |
Show detailed patron info |
borrow <pid> <bid> |
Borrow a book |
renew <pid> <bid> |
Renew a borrowed book |
return <pid> <bid> |
Return a borrowed book |
loadgui |
Launch the Swing GUI |
help |
Show this help message |
exit |
Exit the program |
Data is persisted in resources/data/ as plain text files:
books.txt— Book recordspatrons.txt— Patron recordsloans.txt— Loan records
All data is loaded on startup and saved on exit.
- Java (standard edition, no frameworks)
- Swing — GUI toolkit
- JUnit 5 + Mockito — Unit testing
- Plain text files — Data persistence