A Java-based console application for managing library resources β including books, magazines, and users (students and professors). Built using core Object-Oriented Programming principles: Inheritance, Polymorphism, Abstraction, and Interfaces.
- Features
- Project Structure
- Class Overview
- How to Run
- Usage Guide
- OOP Concepts Used
- Known Limitations
- π Add and remove Books and Magazines
- π€ Register and manage Students and Professors
- π Borrow and return library items
- π View all items or user details by ID
- π§± Clean, menu-driven console interface
- π± Pre-loaded demo data on startup
LibraryManagementSystem/
β
βββ mainLibraryManagement.java # Entry point β main menu & program flow
β
βββ Models/
β βββ Library_Item.java # Base class for all library items
β βββ Book.java # Extends Library_Item
β βββ Magazine.java # Extends Library_Item
β βββ Author.java # Represents a book's author
β
βββ Users/
β βββ User.java # Base class for all users
β βββ Student.java # Extends User (books only)
β βββ Professor.java # Extends User (books & magazines)
β
βββ Library/
β βββ Library.java # Manages the collection of items
β
βββ Managers/
β βββ userManager.java # Handles all user registration & lookup
β
βββ Interfaces/
βββ itemOperations.java # Interface for item operations
βββ UserOperations.java # Interface for user operations
βββ BooksOperation.java # Interface for book operations (reserved)
βββ MagazineOperations.java # Interface for magazine operations (reserved)
The parent class for all items in the library.
| Field | Type | Description |
|---|---|---|
itemId |
String |
Unique identifier |
Tittle |
String |
Title of the item |
isAvailable |
Boolean |
Whether the item can be borrowed |
Key Methods:
borrowItem()β Marks item as borrowedreturnItem()β Marks item as returneddisplayDetails()β Prints item info
Represents a book with an associated Author.
Represents a magazine with an issueNumber.
Stores author details: name, biography, and total books published.
The parent class for library users. Each user can borrow one item at a time.
| Field | Type | Description |
|---|---|---|
userId |
String |
Unique user ID |
name |
String |
User's name |
maxBorrowLimit |
short |
Max items allowed (default: 1) |
Key Methods:
borrow(Library_Item)β Borrows an itemreturnItem()β Returns the currently borrowed itemshowBorrowedItems()β Displays what the user has borrowed
- Can only borrow Books (not magazines)
- Can borrow both Books and Magazines
Maintains an array of up to 10 library items.
| Method | Description |
|---|---|
addItem(item) |
Adds a new item |
removeItem(itemId) |
Removes item by ID |
displayItems() |
Lists all items |
Manages up to 20 users.
| Method | Description |
|---|---|
registerStudent(id, name) |
Registers a new student |
registerProfessor(id, name) |
Registers a new professor |
removeUser(id) |
Removes a user by ID |
displayAllUsers() |
Lists all users |
displayUserById(id) |
Shows details for one user |
findUser(id) |
Returns a User object by ID |
- Java JDK 11 or higher installed
- A terminal or IDE (IntelliJ, Eclipse, VS Code)
1. Clone or download all .java files into one folder.
2. Compile all files:
javac *.java3. Run the main class:
java mainLibraryManagementπ‘ The system loads 2 demo books and 1 demo magazine automatically on startup.
Once running, you'll see the main menu:
ββββββββββββββββββββββββββββββββββββββββ
β LIBRARY MANAGEMENT SYSTEM β
β βββββββββββββββββββββββββββββββββββββββ£
β 1. User Management β
β 2. Book Management β
β 3. Magazine Management β
β 4. Borrow / Return β
β 0. Exit β
ββββββββββββββββββββββββββββββββββββββββ
- Register a new Student or Professor with an ID and name
- Remove a user by their ID
- View all registered users or look up one by ID
- Add a new book by entering ID, title, and author details
- Remove a book by its ID
- View all items in the library
- Add a new magazine with an ID, title, and issue number
- Remove a magazine by ID
- View all items
- Enter your User ID
- A list of available items is shown
- Pick an item number to borrow
- To return, enter your User ID and your item is returned automatically
β οΈ Students can only borrow Books. Professors can borrow both Books and Magazines.
| Concept | Where Applied |
|---|---|
| Inheritance | Book, Magazine extend Library_Item; Student, Professor extend User |
| Polymorphism | displayDetails() overridden in Book and Magazine; borrow() overridden in Student |
| Abstraction | Library_Item and User act as abstract base classes |
| Interfaces | itemOperations, UserOperations define contracts for Library and userManager |
| Encapsulation | Private fields with controlled access via methods across all classes |
- The library can hold a maximum of 10 items and 20 users (fixed array size)
- Each user can only borrow one item at a time
- Data is not persisted β everything resets when the program exits
- The
BooksOperationandMagazineOperationsinterfaces are defined but not yet fully implemented - The
removeItem()method inLibrary.javahas a minor bug where "Item not found" prints for every non-matching entry during a loop (not just when the item is truly absent)
- Add file or database persistence (save/load data)
- Increase borrow limit per user type
- Add search functionality by title or author
- Implement due dates and late fee tracking
- Build a GUI using Java Swing or JavaFX
Built as a Java OOP learning project demonstrating real-world class design, interface-driven development, and clean menu-based console interaction.