0% found this document useful (0 votes)
10 views

java project 2

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

java project 2

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

Library management system 1BI23IS144

1BI23IS143

CONTENTS Page No.


CHAPTER 1 : INTRODUCTION 1
1.1 Definition
1.2 About

CHAPTER 2 : IMPLEMENTATION
2
2.1 TaskOperations Interface
2.2 TaskManager Class
2.3 Task Class

CHAPTER 3 : ALGORITHM
5

CHAPTER 4 : SOURCE CODE


7

CHAPTER 5 : OUTPUT
11

CHAPTER 6 : FUTURE IMPLEMENTATION


13

CHAPTER 7 : CONCLUSION
14

DEPT OF ISE, BIT 1 2024 - 25


Library management system 1BI23IS144
1BI23IS143
CHAPTER 1 INTRODUCTION

1.1 Definition

Chapter 1

INTRODUCTION

1.1Definition
A Library Management System is a computerized system designed to track
and manage the books, journals, and other resources available in a library. It
handles user memberships, keeps records of borrowed items, and ensures
timely returns. It automates the cataloging process, enabling quick access to
books and minimizing human errors. Built using programming languages
like Java, it provides a user-friendly interface for both administrators and
patrons.

1.2 About
The Library Management System in Java is typically built using object-
oriented principles, leveraging Java’s capabilities such as classes, objects,
inheritance, and polymorphism to ensure flexibility, reusability, and
maintainability. The system can be integrated with a database, like MySQL,
to store information such as book details, user data, and transaction history.

DEPT OF ISE, BIT 2 2024 - 25


Library management system 1BI23IS144
1BI23IS143

CHAPTER 2

IMPLEMENTATION

The library management system is implemented using Java and follows


Object-Oriented Programming (OOP) principles. It consists of the
following key components:

2.1 TaskOperations Interface


● The TaskOperations interface defines the operations that can be
performed in the library management system. By using an interface,
we ensure that the different classes implementing the interface will
have consistent method signatures, promoting modularity and
maintainability. Some common methods in this interface might
include:
● addBook(Bookm book): Adds a new book to the list.
• removeBook(String bookID): Removes a book from the
library using its unique identifier.
• issueBook(String bookID, String memberID): Issues a
book to a member.
• returnBook(String bookID, String memberID): Returns
a book from a member.
• searchBook(String keyword): Searches for a book by title,
author, or other parameters.
• generateReport(): Generates various reports like overdue
books, most borrowed books, etc.

2.2 TaskManager Class


The TaskManager class implements the TaskOperations interface. It
manages a list of Task objects and provides implementations for the methods
defined in the TaskOperations interface. Key features of this class include:

• Adding tasks: When a new task is created, it automatically receives


a unique task ID.

DEPT OF ISE, BIT 3 2024 - 25


Library management system 1BI23IS144
1BI23IS143
• Marking tasks as done: The task is marked as completed when the
user specifies the task's ID.
• Displaying tasks: All tasks are displayed with their current status
(either "Done" or "Pending").

2.3 Task Class

The Task class represents individual tasks within the library


management system. Each task has:
● ID: A unique identifier assigned to each task.
● Description: A brief description of the task.
● Status: A boolean indicating whether the task is completed (true) or
still pending (false).

Methods in the Task class:

● markAsDone(): Marks the task as completed.


● toString(): Returns a string representation of the task, displaying
the ID, description, and status.

2.4Todo Class
The LibraryManagementSystem class is the core of the application,
handling user interactions. It continuously prompts the user for actions like
adding tasks, marking tasks as done, and viewing tasks. It provides a simple
text-based interface for users to interact with the task manager. It uses the
TaskManager object to perform operations related to tasks.

2.5 Main Classs

The Main class is responsible for starting the application. It creates an


instance of the ToDoList class and invokes its run() method to initiate the
task management process.

DEPT OF ISE, BIT 4 2024 - 25


Library management system 1BI23IS144
1BI23IS143

CHAPTER 3
ALGORITHM
:
• Initialize the System:
o Initialize lists for books and members (e.g., bookCatalog, ).
o Initialize the system by providing options for the user to
interact
• Add a Book:
o Input the book details (bookID, title, author).
o Check if the bookID already exists.
o If not, create a new Book object and add it to the
bookCatalog.
• Remove a Book:
o Input the book ID to remove.
o Search for the book in the catalog.
o If the book is found, remove it from the bookCatalog.
• Add a Member:
o Input member details (memberID, name).
o Create a new Member object and add it to the membersList.
• Issue a Book:
o Input the book ID and member ID.
o Check if the book is available (i.e., not issued).
o If available, update the book's status to issued and add the
book to the member's borrowed list.
• Return a Book:
o Input the book ID and member ID.
o Check if the member has borrowed the book.
o If the book is found, update the book's status to available
and remove the book from the member's borrowed list.
• Search for a Book:
o Input a keyword (title or author).
o Search the bookCatalog for matching books.
o If found, display the book details; if not, show a "No books
found" message.
• Generate Reports:
o Generate reports on overdue books, most borrowed books,
etc.
o Display the report in a readable format.

DEPT OF ISE, BIT 5 2024 - 25


Library management system 1BI23IS144
1BI23IS143

CHAPTER 4

SOURCE CODE
import java.util.ArrayList;
import java.util.Scanner;

class Book {
private String title;
private String author;

// Constructor
public Book(String title, String author) {
this.title = title;
this.author = author;
}

// Getters
public String getTitle() {
return title;
}

public String getAuthor() {


return author;
}

@Override
public String toString() {
return "Title: " + title + ", Author: " + author;
}
}

public class LibraryManagementSystem {


private static ArrayList<Book> books = new ArrayList<>();
private static Scanner scanner = new Scanner(System.in);

public static void main(String[] args) {

DEPT OF ISE, BIT 6 2024 - 25


Library management system 1BI23IS144
1BI23IS143
int choice;
do {
System.out.println("\n=== Library Management System ===");
System.out.println("1. Add a Book");
System.out.println("2. View All Books");
System.out.println("3. Search for a Book");
System.out.println("4. Remove a Book");
System.out.println("5. Exit");
System.out.print("Enter your choice: ");
choice = scanner.nextInt();
scanner.nextLine(); // Consume newline character

switch (choice) {
case 1:
addBook();
break;
case 2:
viewBooks();
break;
case 3:
searchBook();
break;
case 4:
removeBook();
break;
case 5:
System.out.println("Exiting the system. Goodbye!");
break;
default:

System.out.println("Invalid choice. Please try again.");


}
} while (choice != 5);
}

private static void addBook() {


System.out.print("Enter the book title: ");
String title = scanner.nextLine();
System.out.print("Enter the author: ");

DEPT OF ISE, BIT 7 2024 - 25


Library management system 1BI23IS144
1BI23IS143

String author = scanner.nextLine();

books.add(new Book(title, author));


System.out.println("Book added successfully!");
}

private static void viewBooks() {


if (books.isEmpty()) {
System.out.println("No books available in the library.");
} else {
System.out.println("\nBooks in the Library:");
for (int i = 0; i < books.size(); i++) {
System.out.println((i + 1) + ". " + books.get(i));
}
}
}

private static void searchBook() {


System.out.print("Enter the title or author to search: ");
String keyword = scanner.nextLine();

boolean found = false;


for (Book book : books) {
if (book.getTitle().equalsIgnoreCase(keyword) ||
book.getAuthor().equalsIgnoreCase(keyword)) {
System.out.println("Found: " + book);
found = true;
}
}

if (!found) {
System.out.println("No book found with the given title or author.");
}
}

private static void removeBook() {


System.out.print("Enter the title of the book to remove: ");
String title = scanner.nextLine();

DEPT OF ISE, BIT 8 2024 - 25


Library management system 1BI23IS144
1BI23IS143

boolean removed = false;


for (Book book : books) {
if (book.getTitle().equalsIgnoreCase(title)) {
books.remove(book);
System.out.println("Book removed successfully!");
removed = true;
break;
}
}

if (!removed) {
System.out.println("No book found with the given title.");
}
}
} }

private static void viewBooks() {


if (books.isEmpty()) {
System.out.println("No books available in the library.");
} else {
System.out.println("\nBooks in the Library:");
for (int i = 0; i < books.size(); i++) {
System.out.println((i + 1) + ". " + books.get(i));
}
}
}

private static void searchBook() {


System.out.print("Enter the title or author to search: ");
String keyword = scanner.nextLine();

boolean found = false;


for (Book book : books) {
if (book.getTitle().equalsIgnoreCase(keyword) ||
book.getAuthor().equalsIgnoreCase(keyword)) {
System.out.println("Found: " + book);
found = true;
}

DEPT OF ISE, BIT 9 2024 - 25


Library management system 1BI23IS144
1BI23IS143
}

if (!found) {
System.out.println("No book found with the given title or author.");
}
}

private static void removeBook() {


System.out.print("Enter the title of the book to remove: ");
}

DEPT OF ISE, BIT 10 2024 - 25


Library management system 1BI23IS144
1BI23IS143

CHAPTER 5
OUTPUT
Example output:

=== Library Management System ===


1. Add a Book
2. View All Books
3. Search for a Book
4. Remove a Book
5. Exit
Enter your choice: 1
Enter the book title: Java Basics
Enter the author: John Doe
Book added successfully!

Enter your choice: 2


Books in the Library:
1. Title: Java Basics, Author: John Doe

Enter your choice: 3


Enter the title or author to search: John Doe
Found: Title: Java Basics, Author: John Doe

Enter your choice: 4


Enter the title of the book to remove: Java Basics
Book removed successfully!

Enter your choice: 5


Exiting the system. Goodbye!

DEPT OF ISE, BIT 11 2024 - 25


Library management system 1BI23IS144
1BI23IS143

CHAPTER 6

FUTURE IMPLEMENTATION
1. Persistent Storage (File/Database Integration):

Description: Implement task persistence by saving tasks to a file or database, ensuring


they are retained across sessions.
Implementation Idea: Use file I/O (JSON/CSV) or a lightweight database (SQLite) to
store and retrieve tasks.

2. Task Prioritization & Deadlines:

Description: Add prioritization and deadline features to help users manage tasks more
effectively.
Implementation Idea: Include fields for task priority and due dates, and allow sorting
tasks by priority or deadlines.

3. Graphical User Interface (GUI):

Description: Develop a GUI using JavaFX or Swing for a more user-friendly


experience compared to the command line.
Implementation Idea: Create buttons, task lists, and visual indicators for task statuses
to enhance usability.

4. Task Categories/Tags:

Description: Enable task categorization (e.g., Work, Personal) or tagging for better task
organization.
Implementation Idea: Add a category or tags field in the Task class and allow filtering
by categories.

5. Recurring Tasks:

DEPT OF ISE, BIT 14 2024 - 25


.

DEPT OF ISE, BIT 13 2024 - 25


Library management system 1BI23IS144
1BI23IS143

CHAPTER 7

CONCLUSION

In conclusion, a Library Management System (LMS) is a vital tool that automates and streamlines
various library operations, such as managing books, members, and transactions. By reducing manual
work, it increases efficiency, accuracy, and accessibility within the library environment. The system
ensures that tasks like book issuing, returning, cataloging, and member management are carried out
smoothly, improving the overall experience for both library staff and users. Implemented using Java,
the system leverages object-oriented principles, offering scalability, flexibility, and ease of
maintenance. An LMS is crucial for modern libraries, enabling them to manage their resources more
effectively, while also providing features that can be expanded over time, such as reports, fines, and
book reservations. Ultimately, it ensures a well-organized and user-friendly library environment that
supports efficient operations and a better experience for all users.

DEPT OF ISE, BIT 14 2024 - 25

You might also like