A menu-driven Java console application for managing a library catalog and its patrons. It lets a user borrow, return, and place holds on books, and add, remove, search, and print books from a catalog of 11,000+ records stored in CSV files.
Built as a two-person project for ICS4U1 (Computer Science) at Don Mills Collegiate Institute, May to June 2025.
- Borrow and return books by barcode and student number
- Holds: add and remove holds on books
- Book management: add, remove, search, and print books
- Adding a book validates the barcode, ISBN, call number, and author, and classifies it as Fiction or Non-Fiction
- Books can be removed by title, barcode, or ISBN
- Two kinds of search:
- Specific search finds an exact book using binary search
- Keyword search finds every book whose title or author contains a given word
- Patron management: register, remove, search, and print patrons
- Persistent storage: the catalog and patron list are loaded from CSV files on startup and saved when you exit
- Java (tested with Java 21)
- No external libraries
A Java Development Kit (JDK). Check with:
java -version
javac -versionDownload or clone the repository, open a terminal in the project folder, and run:
javac Book.java Fiction.java NonFiction.java Patron.java Library.java Main.java
java MainThe program reads its data files using relative paths, so run it from the folder that contains library.csv, patrons.csv, and write.txt.
The main menu looks like this:
(1) Borrow
(2) Return
(3) Books
(4) Patrons
(5) Holds
(6) Exit
(7) DEBUG
Type the number of an option and press Enter. When you choose Exit, the program asks whether you want to save. Changes are only written to the CSV files if you choose Yes. Option 7 turns on debug output that prints what the sorting, searching, and file-reading code is doing.
| File | Purpose |
|---|---|
Main.java |
Console interface and menu logic |
Library.java |
Loads and saves data, keeps the catalog sorted, and handles searching, borrowing, returning, and holds |
Book.java |
Book class, input validation, and comparison logic |
Fiction.java, NonFiction.java |
Subclasses of Book used to keep separate Fiction and Non-Fiction lists. Redundant, but the assignment required inheritance |
Patron.java |
Patron class and patron validation and search |
library.csv |
Book catalog (title, author, barcode, call number, ISBN, status, patron, hold status) |
patrons.csv |
Patron records (student number, phone number, email, books checked out) |
write.txt |
Counter of how many times the program has been run |
- Sorted lists: when the program starts,
Libraryreadslibrary.csvline by line and loads every book into several lists, each sorted by a different field: title, author, barcode, call number, and ISBN. Separate Fiction and Non-Fiction lists are also kept. - Custom CSV parser: titles and authors often contain commas (for example, "Lindsey, Cameron"), so the parser tracks whether it is inside quotation marks before treating a comma as a separator.
- Merge sort and sorted insertion: the lists are sorted with merge sort on load. New books are inserted into each list in the correct position instead of re-sorting the whole catalog.
- Binary search finds an exact book quickly in whichever list is sorted by the field being searched. Sequential search is used for keyword matches, since a keyword can appear anywhere in a field.
- Fiction detection: a book is classified as Fiction or Non-Fiction from its call number (an "F" prefix, or the absence of a Dewey Decimal number).
- Ibraheem Siddiqui:
Book,Fiction, andNonFictionclasses; book file reading and saving; catalog sorting and searching; the book management and search menus inMain - Imaad Kotadia:
Patronclass; patron loading, saving, and sorting; borrow, return, and hold logic; the patron and holds menus inMain
- ISBN validation only checks that the value is numeric. It does not check the length or the check digit.
FictionandNonFictionshare nearly identical code and could be replaced with a single generic method.Main.javais large; the menus could be split into smaller methods.- Data is stored in CSV files. A database would handle larger catalogs and multiple users better.
This project was created for a school course. No license is specified.