Java OOP Exercise: Library Management System
Goal:
Build a mini system to manage a library with books and users using Object-Oriented Programming
concepts (no interfaces).
Requirements:
1 Create class Book with attributes: title, author, isAvailable
2 Methods: borrowBook(), returnBook(), toString()
3 Create class User with attributes: name, borrowedBooks (ArrayList)
4 Methods: borrow(Book), returnBook(Book), printBorrowedBooks()
5 Create class Library with attributes: books, users (ArrayList)
6 Methods: addBook(), addUser(), showAvailableBooks(), findBook(String title),
borrowBook(User, String), returnBook(User, String)
Rules:
1 A user cannot borrow a book if it is already borrowed
2 A user cannot return a book they do not have
3 Use encapsulation (private fields)
4 Use constructors properly
Expected Output When Running main():
1 Available books:
2 - Book A
3 - Book B
5 Ali borrows Book A
6 Available books now:
7 - Book B
9 Ali tries to borrow Book A again:
10 Error: Book is not available
12 Ali returns Book A
13 Available books now:
14 - Book A
15 - Book B