Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
5 views

Advanced Programming Project

The document outlines the design and functionality of a Library Management System developed in Java, which allows users to manage library operations such as adding, borrowing, and returning books through a graphical user interface (GUI). Key classes include 'library', 'book', 'NotFound', 'gui', and 'main', each with specific methods and attributes to facilitate book management and user interaction. The system includes features like capacity setting, search functionality, and exception handling for invalid inputs and library limits.

Uploaded by

dowymoragy
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Advanced Programming Project

The document outlines the design and functionality of a Library Management System developed in Java, which allows users to manage library operations such as adding, borrowing, and returning books through a graphical user interface (GUI). Key classes include 'library', 'book', 'NotFound', 'gui', and 'main', each with specific methods and attributes to facilitate book management and user interaction. The system includes features like capacity setting, search functionality, and exception handling for invalid inputs and library limits.

Uploaded by

dowymoragy
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

Fall 2025

(CSCI217)
Advanced Computer Programming and Concept
Project

Instructor: Dr. Sameh Abd El Rahman


TA: Rahma Mohamed
Date: 24/12/2024

Asmaa Hazem Ali 211001680


Mariam Yasser Mattar 211000120
Hla Hatem Ali 211001679
Radwa Mohamed El-Maraghy 211000446
Tallah Khaled 241000705
Library Management System Documentation
Our Library Management System is a simple Java application that allows users to manage a library
by adding, removing, borrowing, returning books, in addition to viewing, or saving the library
details, resetting it, exiting, or searching for a certain book. We also added a sound feature that
plays when certain buttons are clicked. The system also includes a graphical user interface (GUI)
for interaction with the user.

Classes Overview
1. library Class:
o Purpose: Represents the library as a collection of books.
o Key Methods:
▪ addbook(book b): Adds a book to the library.
▪ removebook(int id, book b): Removes a book from the library using its ID.
▪ borrow_book(int id, int borrowing_period, book b): Allows borrowing of a
book.
▪ return_book(int id, book b): Returns a borrowed book to the library.
▪ isfull(): Checks if the library has reached its capacity.
▪ displayallbooks(): Displays all the books in the library.
▪ notfound(int id): Throws an exception if the book with the given ID is not
found.
▪ searchBook(String title): Searches for a book by its title.
▪ resetLibrary(): Resets the library, clearing all books and data.
o Attributes:
▪ capacity: The maximum number of books that the library can hold.
▪ totalbooks: The total number of books in the library.
▪ books[]: An array or collection holding the current books in the library.
2. book Class:
o Purpose: Represents a book in the library.
o Key Methods:
▪ setbook_name(String book_name): Sets the book name.
▪ getbook_id(): Returns the book's ID.
▪ getbookname(): Returns the book's name.
▪ setcategory(String category): Sets the category of the book.
▪ getcategory(): Returns the category of the book.
▪ setborrowing_period(int borrowing_period): Sets the borrowing period for
the book.
▪ availability(book k): Checks if the book is available for borrowing.
▪ setreturnn_date(LocalDate returndate): Sets the return date for the book.
▪ getreturnn_date(): Returns the book's return date.
▪ displaybookdetails(): Displays the details of the book.
▪ gettotalbooks(): Returns the total number of books.
o Attributes:
▪ book_name: Name of the book.
▪ book_id: ID of the book.
▪ category: Category of the book (e.g., "History", "Maths").
▪ notborrowed: Boolean flag indicating whether the book is available for
borrowing.
▪ borrowing_date: The date when the book was borrowed.
▪ returndate: The date when the book is due for return.
3. NotFound Class:
o Purpose: A custom exception thrown when a book is not found in the library.
o Key Methods:
▪ Constructor for the exception, which takes a message as a parameter.
4. gui Class:
o Purpose: Handles the graphical user interface for the library system.
o Key Methods:
▪ setupframe(): Sets up the initial window and components.
▪ updateOutput(String text): Updates the output area with text.
▪ setuplisteners(): Sets up event listeners for all buttons and inputs in the GUI.
▪ disableButtons(): Disables all action buttons in the GUI.
▪ enableButtons(): Enables all action buttons in the GUI.
▪ playSound(String soundFile): Plays the sound effect from the specified file
path.
o Attributes:
▪ frame: The main window of the GUI.
▪ panel: The main content panel of the GUI.
▪ panel2: A secondary panel holding the buttons.
▪ b1, b2, b3, etc.: Buttons for interacting with the library system (add, borrow,
return, etc.).
▪ label1, label2: Labels used for displaying text.
▪ tf1: TextField for user input (capacity, book ID, etc.).
▪ ta1: TextArea for displaying the output (e.g., list of books, borrowing info).
▪ sp: JScrollPane for the output area.
▪ lib: Instance of the library class representing the current library.
▪ combobox: JComboBox for selecting book categories.
▪ f: File object for saving library details.
5. main Class:
o Purpose: Entry point of the application. Initializes and runs the GUI.
o Key Methods:
▪ main(String[] args): Initializes the gui object and starts the application.

Key Features
1. Library Capacity: The user should set the maximum capacity of the library, and actions
like adding books are restricted based on this capacity.
2. Book Management: Users can add, borrow, return, and remove books from the library.
Each book has details like title, category, availability status, borrowing period, and return
date.
3. Search Functionality: Users can search for a book by its title.
4. Borrowing System: The system tracks whether a book is available for borrowing and
prevents users from borrowing a book that is already borrowed.
5. User Interface: A user-friendly graphical interface for interacting with the library system.
It includes buttons for all major actions (e.g., add book, borrow book, remove book, etc.).
6. Book Categories: Books can be categorized (e.g., "History", "Maths",
"Science","Biology", "Politics"), and the user selects a category when adding a book.
7. Search for Books: The user can search for a specific book by its title using the search
button. The search result will be displayed in the output area.

Instructions for Using the System:


1. Setting Capacity: Enter a numeric value in the text field and press Enter to set the library's
capacity.
2. Add a Book: Click "Add Book" to enter the name and category of the book.
3. Borrow a Book: Click "Borrow Book" and enter the book's ID. If the book is available,
input the borrowing period.
4. Return a Book: Click "Return Book" and enter the book's ID to return it.
5. Remove a Book: Click "Remove" and enter the book's ID to remove it from the library.
6. View All Books: Click "View All Books" to display all books in the library.
7. Reset Library: Click "Reset" to clear the library and reset the system.
8. Search for a Book: Click "Search" to search for a book by its title.

Exception Handling:
• Invalid Input: Users are alerted if invalid inputs (e.g., empty fields, non-numeric capacity,
etc.) are entered.
• Book Not Found: If a user tries to borrow, return, or remove a book that doesn't exist, a
custom NotFound exception is thrown.
• Library Full: If the library has reached its maximum capacity, the user is informed and
cannot add more books.
• Empty Library: If there are no books to borrow or return, an appropriate message is
shown.
• File Handling: If there is an issue saving or loading the library details, an error message
is shown.
This Library Management System provides an easy-to-use interface for managing books in a
library, making tasks such as adding, borrowing, returning, and removing books simple and
efficient. The use of Java Swing for the GUI ensures a user-friendly experience, and the backend
logic is designed to handle all basic library operations.
Simulation:
The following window appears when the code runs; all the buttons are disabled until the user enters
the capacity.
All of the following snapshots show what happens upon entering data or choosing a button.
Capacity is entered.

Click View All Books.


Click on the Add Book button.
If you didn’t enter a name and pressed cancel or closed the window, the following error appears.
Enter the book name.

Select the category and press OK.


If you didn’t enter a name and pressed cancel or closed the window, the following error appears.
Press View all Books.
The system asks the user whether she/he wants to save the library details as a text file. If Yes
button is pressed, then the file is successfully updated with the library details.
Click Borrow Book and enter the book id for the book to be borrowed and press OK.
Enter the borrowing period and press OK.
If you entered an id for a book that is already borrowed, the date it will be available at is then
displayed.
When you attempt to remove a book that is borrowed, the following appears.
Click Return Book and enter the id.
Search the book by title by clicking the search icon on the top right.
Now remove the book by entering the id.
Click view library details, and now we can see that the book is removed.
Reset the library.

We also added a feature to know the function of each component in our system.
For example,

You might also like