Skip to content

http-ray/Library

Repository files navigation

Library

Online Library Management System

🧠 Overview

This Java project simulates a simple Online Library Management System that allows users to:

Borrow books

Return books

Check availability

Handle custom exceptions for invalid book IDs and overdue books

It follows an Agile XP (Extreme Programming) style, completed across three sprints. All functionality is demonstrated through an interactive menu-based console program.

Sprints Summary Sprint 1 – Core Setup

Created Book, User, and Library classes.

Implemented lists to store users and books.

Added basic getters, setters, and simple display functions.

Sprint 2 – Borrowing System

Added borrowBook() logic in the Library class.

Introduced InvalidBookIDException for invalid book lookups.

Updated User to track borrowed books.

Sprint 3 – Return & Exception Handling

Added returnBook() to manage book returns.

Implemented OverdueBookException for late returns.

Added a skip-time feature to simulate overdue penalties.

Displayed penalty messages when returning overdue books.

Interactive Menu (LibTester.java)

The program uses a console menu so users can test every function themselves. This makes testing and demonstration much easier than hard-coded test cases.

Menu Options:

  1. List books
  2. List users
  3. Borrow a book
  4. Return a book
  5. Check availability
  6. Skip time (simulate days passing)
  7. Exit

🕹️ How to Use

Start from option 1 or 2 to view existing book and user IDs.

Use those IDs when prompted for borrowing or returning.

After borrowing, try the “Skip time” option to simulate late returns and trigger the OverdueBookException.

Watch how the system handles valid, invalid, and overdue operations in real time.

⚙️ Features Demonstrated

✅ Object-Oriented Programming (classes, constructors, encapsulation)

✅ Custom exceptions (InvalidBookIDException, OverdueBookException)

✅ Exception handling with try / catch blocks

✅ Logical borrowing / returning system

✅ Real-time menu interaction for easy testing

✅ Simple time-skip simulation for overdue penalty testing

Why I Chose a Menu System

I used a menu-based program instead of static test cases to make testing interactive and visual. It allows anyone (including the instructor) to test all functions of the library directly — borrowing, returning, invalid IDs, and overdue exceptions — without editing code.

This approach also makes it easier to demonstrate and verify that each Sprint’s goals are working correctly.

Follow the menu prompts to interact with the library.

🧾 Example Run Welcome to the Online Library (demo)

--- Menu ---

  1. List books
  2. List users
  3. Borrow a book
  4. Return a book
  5. Check availability
  6. Skip time (simulate days passing)
  7. Exit

Choose: 3 Enter user ID: U001 Enter book ID: B001 Ray borrowed "Clean Code".

Choose: 6 Enter number of days to skip: 20 ⏩ Skipped ahead 20 day(s).

Choose: 4 Enter user ID: U001 Enter book ID: B001 Penalty: Overdue return for book B001 (6 day(s) late).

About

Online Library Management System

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages