[go: up one dir, main page]

0% found this document useful (0 votes)
21 views26 pages

Anwesha Java

The document outlines a project on a Java-based Library Management System developed by students from ASBM University. It details the project's objectives, requirements, key features, and a step-by-step implementation guide, including code snippets for various classes such as Book, User, Library, and Admin. The project aims to manage library operations effectively and suggests potential improvements like database integration and GUI development.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views26 pages

Anwesha Java

The document outlines a project on a Java-based Library Management System developed by students from ASBM University. It details the project's objectives, requirements, key features, and a step-by-step implementation guide, including code snippets for various classes such as Book, User, Library, and Admin. The project aims to manage library operations effectively and suggests potential improvements like database integration and GUI development.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 26

ASBM SCHOOL OF INFORMATION

SYSTEM
ASBM UNIVERSITY
SHIKSHA VIHAR, BHOLA, CHANDAKA, BHUBANESWAR-754012, ODISHA

PROJECT ON JAVA PROGRAMMING

Submitted By:-

Anwesha Priyadarshani
Jyotisankar Rout
Subhasree Muduli
Pravasini Malia
Suryakanta Nayak
Suryasmita Sahoo
Trilokesh Sahu
PROGRAMME: MCA

SEMESTER: 2nd , BATCH: 2024-26

Submitted To:

Prof.Rasheswari B.Ray
Professor

ASBM School of Information System


ACKNOWLEDGEMENT

We would like to express our sincere


gratitude to prof.Rasheswari B.Roy for
her valuable guidance and support
throughout the course of this project. Her
insightful feedback and expert advice were
instrumental in shaping the direction of
our assignment. Her encouragement and
patience have been truly inspiring. We are
deeply grateful for her

contribution to this work.

SIGNATURE
PROJECT 2:-
LIBRARY MANAGEMENTSYSTEM

Project Overview:
The project is a simple system that helps
manage library operations, such as:
 Managing books (adding, removing,
searching)
 Managing users (registering new users,

deleting users)
 Borrowing and returning books

 Keeping track of the due dates for


borrowed books
Project Requirements:
1. Java Development Kit (JDK) –
Ensure you have JDK installed.
2. Text Editor/IDE – Use any text
editor (like Notepad++) or IDE (Eclipse,
IntelliJ IDEA, NetBeans).
3. File handling or Database – In this
simple version, we will use file handling
for storing book and user information.
Key Features:
1. Admin and User Modules:
o Admin can add, remove, and search

books.
o Admin can register users.

o Users can borrow/return books.

2. Classes/Objects:
o Book: Stores book details such as
book ID, title, author, status
(available/borrowed).
o User: Stores user details such as
user ID, name, and borrowed books.
o Library: Manages operations (add
books, delete books, list books).
o Transaction: Keeps track of book
borrow and return operations.
o Admin: Admin-related operations
like adding/removing users or books.

Step-by-Step Implementation:
1. Create the Book Class:

java
Copy
public class Book {
private int bookId;
private String title;
private String author;
private boolean isAvailable;

// Constructor
public Book(int bookId, String title,
String author) {
this.bookId = bookId;
this.title = title;
this.author = author;
this.isAvailable = true;
}
// Getters and Setters
public int getBookId() {

return bookId;
}

public String getTitle() {


return title;
}

public String getAuthor() {

return author;
}

public boolean isAvailable() {


return isAvailable;
}

public void setAvailable(boolean


available) {
isAvailable = available;
}

// Display Book details


public void displayBookInfo() {
System.out.println("ID: " + bookId +
", Title: " + title + ", Author: " + author +
", Available: " + (isAvailable ? "Yes" :
"No"));
}
}

2. Create the User Class:


java
Copy
import java.util.ArrayList;

public class User {


private int userId;
private String name;
private ArrayList<Book>
borrowedBooks;

// Constructor
public User(int userId, String name) {

this.userId = userId;
this.name = name;
this.borrowedBooks = new
ArrayList<>();
}

// Methods to borrow and return books


public void borrowBook(Book book) {
if (book.isAvailable()) {

borrowedBooks.add(book);
book.setAvailable(false);
System.out.println("You have
borrowed: " + book.getTitle());
} else {
System.out.println("Sorry, this book
is not available.");
}
}

public void returnBook(Book book) {

if (borrowedBooks.contains(book)) {
borrowedBooks.remove(book);
book.setAvailable(true);
System.out.println("You have
returned: " + book.getTitle());
} else {
System.out.println("This book was
not borrowed.");
}
}

// Display user details and borrowed


books
public void displayUserInfo() {
System.out.println("User ID: " +
userId + ", Name: " + name);
if (borrowedBooks.isEmpty()) {
System.out.println("No borrowed
books.");
} else {
System.out.println("Borrowed
Books:");
for (Book book : borrowedBooks) {
System.out.println(book.getTitle(
));
}
}
}
}
3. Create the Library Class:
java
Copy
import java.util.ArrayList;

public class Library {


private ArrayList<Book> books;

// Constructor
public Library() {
this.books = new ArrayList<>();
}

// Add book

public void addBook(Book book) {

books.add(book);

// Remove book

public void removeBook(int bookId) {

books.removeIf(book ->
book.getBookId() == bookId);

}
// List all books

public void listBooks() {

if (books.isEmpty()) {

System.out.println("No books
available in the library.");

} else {

for (Book book : books) {

book.displayBookInfo();

// Search for a book by title

public Book searchBookByTitle(String


title) {
for (Book book : books) {

if
(book.getTitle().equalsIgnoreCase(title)) {

return book;

return null;

4. Create the Admin Class (optional):

java

Copy

public class Admin {

private Library library;

// Constructor
public Admin(Library library) {

this.library = library;

// Add book to library

public void addNewBook(int bookId,


String title, String author) {

Book newBook = new Book(bookId,


title, author);

library.addBook(newBook);

System.out.println("New book added:


" + title);

// Remove book from library

public void removeBook(int bookId) {


library.removeBook(bookId);

System.out.println("Bookremovedsuc
cessfully.");

5.Create the maoin


class(librarymanagement.java)

java

Copy

import java.util.Scanner;

public class LibraryManagementSystem {

public static void main(String[] args) {

Scanner sc = new
Scanner(System.in);
Library library = new Library();

Admin admin = new Admin(library);

User user = null;

while (true) {

System.out.println("\n---- Library
Management System ----");

System.out.println("1. Admin
Login");

System.out.println("2. User Login");

System.out.println("3. Exit");

System.out.print("Enter your
choice: ");

int choice = sc.nextInt();

sc.nextLine(); // Consume newline

switch (choice) {

case 1:
// Admin Login and Operations

System.out.println("AdminLog
ged In");

System.out.println("1. Add
Book");

System.out.println("2.
Remove Book");

System.out.println("3. List
Books");

int adminChoice =
sc.nextInt();

sc.nextLine(); // Consume
newline

if (adminChoice == 1) {
System.out.print("Enter
Book ID: ");

int bookId = sc.nextInt();

sc.nextLine();

System.out.print("Enter
Book Title: ");

String title = sc.nextLine();

System.out.print("Enter
Book Author: ");

String author =
sc.nextLine();

admin.addNewBook(bookId,
title, author);

} else if (adminChoice == 2) {

System.out.print("Enter
Book ID to remove: ");
int bookId = sc.nextInt();

admin.removeBook(bookId)
;

} else if (adminChoice == 3) {

library.listBooks();

break;

case 2:

// User Login and Operations

if (user == null) {

System.out.print("Enter
User ID: ");

int userId = sc.nextInt();

sc.nextLine(); // Consume
newline
System.out.print("Enter User
Name: ");

String name =
sc.nextLine();

user = new User(userId,


name);

System.out.println("1. Borrow
Book");

System.out.println("2. Return Book");

System.out.println("3. View Borrowed


Books");

int userChoice = sc.nextInt();

sc.nextLine(); // Consume
newline
if (userChoice == 1) {

System.out.print("Enter Book Title to


borrow: ");

String title = sc.nextLine();

Book book =
library.searchBookByTitle(title);

if (book != null) {

user.borrowBook(book);

} else {

System.out.println("Book not
found.");

} else if (userChoice == 2) {
System.out.print("Enter Book Title to
return: ");

String title = sc.nextLine();

Book book =
library.searchBookByTitle(title);

if (book != null) {

user.returnBook(book);

} else {

System.out.println("Book not
found.");

} else if (userChoice == 3) {

user.displayUserInfo();

break;
case 3:

System.out.println("Exiting...")
;

return;

Additional Improvements:

1. Database: Instead of storing


information in memory, you can store it
in a database (like MySQL or SQLite).

2. Due Date Tracking: You can add


functionality to keep track of due dates
for borrowed books.
3. GUI Interface: You can extend this
project by adding a graphical user
interface (GUI) using JavaFX or Swing.

Conclusion:

This Java-based Library Management


System is a simple, console-based
implementation with admin and user
functionalities. It provides the basic
operations to manage books and users,
and it can be extended with more
features and improvements, like
integrating a database or adding a
graphical user interface.

You might also like