Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

Course Code: CC109n 

                                   Course Name: Java Programming 2

Program Name: Bsc. Hons Computing             Semester: 8th                                Batch: Jan 2020

Assignment I / II / III: Please Tick (√ ) Assignment Type (Individual/Group): Group

Assignment Title: Final Assignments

Max. Marks: ______                 Date of Allotment: ___________    Date of

Submission: ______________ 

(Write the individual/group members details below):

Name of the Student ID number Contact Number Email Id


Signature

Pramit Neupane 1002057693 9805430918 pramitneupane2011008@iimscollege.edu.np

Sujan BK 1002057667 9823741464 sujan2011057@iimscollege.edu.np

Sujan KC 1002057825 9848303620 sujan2011006@iimscollege.edu.np


Evaluation: ________________________ obtained out of _____________________________________

Evaluator’s Comment:
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________________________
_________________________________________________________________________

-------------------------------------------

Evaluator’s Signature & Date


Table of Contents

Abstract : 3
General Overview of the System : 4
1. UML Diagram: 4
Codes for the project : 5
Conclusion and Future Work 13
References 14
Abstract :
The purpose of Library Management System is to automate the existing manual system by the
help of computerized equipment and full-fledged computer software, fulfilling their
requirements, so that their valuable data/information can be stored for a longer period with easy
accessing and manipulation of the same. The required software and hardware are easily available
and easy to work with.
Library Management System, as described above, can lead to error free, secure, reliable and fast
management system. It can assist the user to concentrate on their other activities rather than
concentrating on the record keeping. Thus it will help organizations in better utilization of
resources. The organization can maintain computerized records without redundant entries. That
means that one need not be distracted by information that is not relevant, while being able to
reach the information. The aim is to automate its existing manual system by the help of
computerized equipment and full- fledged computer software, fulfilling their requirements, so
that their valuable data/information can be stored for a longer period with easy accessing and
manipulation of the same. Basically the project describes how to manage for good performance
and better services for the clients
General Overview of the System :

OOP Project

Project Idea: Library Management System


Description: The Library Management System allows users to manage and keep track of books
in a library. The system will have a GUI that allows users to perform tasks such as adding
books, removing books, updating book information, and searching for books by various criteria.

1. UML Diagram:

scss

| Library Management System |


| |
|+add_book() |
|+remove_book() |
|+update_book_info() |
|+search_book_by_title() |
|+search_book_by_autho |
r() |
|+search_book_by_isbn() |
|
/\
|
| Book |
| |
|+set_title() |
|+set_author |
() |
|+set_isbn() |
|+get_title() |
|+get_author |
() |
|+get_isbn()
|

In this Library Management System, the main class is Library Management System that has
different methods such as add_book(), remove_book(), update_book_info(),
search_book_by_title(), search_book_by_author(), search_book_by_isbn() to perform various
operations.
The system also has a Book class, which has attributes such as title, author, and
isbn.
The use of getter and setter methods has been shown in the Book class. These methods are used
to access and modify the attributes of the Book objects.
Overall, this project idea provides a basic understanding of OOP concepts such as classes,
objects, inheritance, and polymorphism, and also demonstrates how to create a GUI interface for
the system.

Codes for the project :


The java code is based on the UML diagrams and classes according to the relations among the
classes (inheritance or polymorphism).

// Book class public class Book {


private String title; private String author; private String isbn;
public Book(String title, String author, String isbn) { this.title = title;
this.author = author; this.isbn = isbn;
}
public void setTitle(String title) { this.title = title;
}
public void setAuthor(String author) { this.author = author;
}
public void setIsbn(String isbn) { this.isbn = isbn;
}
public String getTitle() { return this.title;
}
public String getAuthor() { return this.author;
}
public String getIsbn() { return this.isbn;
}
}
// FictionBook class
public class FictionBook extends Book { private String genre;
public FictionBook(String title, String author, String isbn, String genre) { super(title, author,
isbn);
this.genre = genre;
}
public void setGenre(String genre) { this.genre = genre;
}
public String getGenre() { return this.genre;
}
}
// NonFictionBook class
public class NonFictionBook extends Book { private String topic;
public NonFictionBook(String title, String author, String isbn, String topic) { super(title,
author, isbn);
this.topic = topic;
}
public void setTopic(String topic) { this.topic = topic;
}
public String getTopic() { return this.topic;
}
}
// LibraryManagementSystem class
import java.util.ArrayList; import java.util.List;
public class LibraryManagementSystem { private List<Book> books;
public LibraryManagementSystem() { this.books = new ArrayList<>();
}
public void addBook(Book book) { this.books.add(book);
}
public void removeBook(Book book) { this.books.remove(book);
}
public void updateBookInfo(Book book, String title, String author, String isbn) {
book.setTitle(title);
book.setAuthor(author); book.setIsbn(isbn);
}
public List<Book> searchBookByTitle(String title) { List<Book> result = new
ArrayList<>();
for (Book book : this.books) {
if (book.getTitle().equalsIgnoreCase(title)) { result.add(book);
}
}
return result;
}
public List<Book> searchBookByAuthor(String author) { List<Book> result = new
ArrayList<>();
for (Book book : this.books) {
if (book.getAuthor().equalsIgnoreCase(author)) { result.add(book);
}
}
return result;
}
public List<Book> searchBookByIsbn(String isbn) { List<Book> result = new
ArrayList<>();
for (Book book : this.books) {
if (book.getIsbn().equalsIgnoreCase(isbn)) { result.add(book);
}
}
return result;
}
}
The other concepts of OOP such as Interface, GUI
// Book interface public interface Book {
public String getTitle(); public String getAuthor(); public String getIsbn();
}
// FictionBook class
public class FictionBook implements Book { private String title;
private String author; private String isbn; private String genre;
public FictionBook(String title, String author, String isbn, String genre) { this.title = title;
this.author = author; this.isbn = isbn; this.genre = genre;
}
public void setTitle(String title) { this.title = title;
}
public void setAuthor(String author) { this.author = author;
}
public void setIsbn(String isbn) { this.isbn = isbn;
}
public String getTitle() { return this.title;
}
public String getAuthor() { return this.author;
}
public String getIsbn() { return this.isbn;
}
public String getGenre() { return this.genre;
}
}
// NonFictionBook class
public class NonFictionBook implements Book { private String title;
private String author; private String isbn; private String topic;
public NonFictionBook(String title, String author, String isbn, String topic) { this.title =
title;
this.author = author; this.isbn = isbn; this.topic = topic;
}
public void setTitle(String title) { this.title = title;
}
public void setAuthor(String author) { this.author = author;
}
public void setIsbn(String isbn) { this.isbn = isbn;
}
public String getTitle() { return this.title;
}
public String getAuthor() { return this.author;
}
public String getIsbn() { return this.isbn;
}
public String getTopic() { return this.topic;
}
}
// Library interface public interface Library {
public void addBook(Book book); public void removeBook(Book book);
public void updateBookInfo(Book book, String title, String author, String isbn); public
List<Book> searchBookByTitle(String title);
public List<Book> searchBookByAuthor(String author); public List<Book>
searchBookByIsbn(String isbn);
}
// LibraryManagementSystem class import java.util.ArrayList;
import java.util.List; import javax.swing.*; import java.awt.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionListener;
public class LibraryManagementSystem implements Library { private List<Book> books;
public LibraryManagementSystem() { this.books = new ArrayList<>();
}
public void addBook(Book book) { this.books.add(book);
}
public void removeBook(Book book) { this.books.remove(book);
}
public void updateBookInfo(Book book, String title, String author, String isbn) {
book.setTitle(title);
book.setAuthor(author); book.setIsbn(isbn);
}
public List<Book> searchBookByTitle(String title) { List<Book> result = new
ArrayList<>();
for (Book book : this.books) {
if (book.getTitle().equalsIgnoreCase(title)) { result.add(book);
}
}
return result;
}
public List<Book> searchBookByAuthor(String author) { List<Book> result = new
ArrayList<>();
for (Book book : this.books) {
if (book.getAuthor().equalsIgnoreCase(author)) { result.add(book);
}
}
return result;
}
public List<Book> searchBookByIsbn(String isbn) { List<Book> result = new ArrayList<>();
for (Book book : this.books) {
if (book.getIsbn().equalsIgnoreCase(isbn)) { result.add(book);
}
}
return result;
}
// GUI components private JFrame frame; private JPanel panel;
private JLabel titleLabel, authorLabel, isbnLabel, genreLabel, topicLabel, resultLabel; private
JTextField titleField, authorField, isbnField, genreField, topicField, searchField; private JButton
addButton, removeButton, updateButton, searchButton;
private JTextArea resultArea;
public void createGUI() {
// Frame
frame = new JFrame("Library Management System");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(500, 500);
frame.setLayout(new GridLayout(1, 2));
// Panel
panel = new JPanel(new GridLayout(7, 2));
// Labels
titleLabel = new JLabel("Title:"); authorLabel = new JLabel("Author:"); isbnLabel = new
JLabel("ISBN:"); genreLabel = new JLabel("Genre:"); topicLabel = new JLabel("Topic:");
resultLabel = new JLabel("Search Results:");
// Text fields
titleField = new JTextField(); authorField = new JTextField(); isbnField = new JTextField();
genreField = new JTextField(); topicField = new JTextField(); searchField = new
JTextField();
// Buttons
addButton = new JButton("Add"); removeButton = new JButton("Remove"); updateButton =
new JButton("Update"); searchButton = new JButton("Search");
// Result area
resultArea = new JTextArea();
resultArea.setEditable(false);
JScrollPane scrollPane = new JScrollPane(resultArea);
// Add components to panel panel.add(titleLabel); panel.add(titleField);
panel.add(authorLabel); panel.add(authorField); panel.add(isbnLabel); panel.add(isbnField);
panel.add(genreLabel); panel.add(genreField); panel.add(topicLabel); panel.add(topicField);
panel.add(addButton); panel.add(removeButton); panel.add(updateButton);
panel.add(searchField); panel.add(searchButton); panel.add(resultLabel);
panel.add(scrollPane);
// Add panel to frame frame.add(panel);
// Button listeners addButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { String title = titleField.getText();
String author = authorField.getText(); String isbn = isbnField.getText(); String genre =
genreField.getText(); String topic = topicField.getText();
if (!title.equals("") && !author.equals("") && !isbn.equals("") &&
(genre.equals("") || topic.equals(""))) { if (genre.equals("")) {
FictionBook book = new FictionBook(title, author, isbn, topic); addBook(book);
} else {
NonFictionBook book = new NonFictionBook(title, author, isbn, genre);
addBook(book);
}
titleField.setText(""); authorField.setText(""); isbnField.setText("");
genreField.setText(""); topicField.setText(""); resultArea.setText("Book added.");
} else {
resultArea.setText("Please fill in all required fields.");
}
}
});
removeButton.addActionListener(new ActionListener() { public void
actionPerformed(ActionEvent e) {
String isbn = isbnField.getText();
if (!isbn.equals("")) { removeBook(isbn); isbnField.setText("");
resultArea.setText("Book removed.");
} else {
resultArea.setText("Please enter ISBN.");
}
}
});
updateButton.addActionListener(new ActionListener() { public void
actionPerformed(ActionEvent e) {
String isbn = isbnField.getText(); String genre = genreField.getText(); String topic =
topicField.getText();
if (!isbn.equals("") && !genre.equals("") && !topic.equals("")) { updateBook(isbn,
genre, topic);
isbnField.setText(""); genreField.setText(""); topicField.setText("");
resultArea.setText("Book updated.");
} else {
resultArea.setText("Please fill in all required fields.");
}
}
});
searchButton.addActionListener(new ActionListener() { public void
actionPerformed(ActionEvent e) {
String query = searchField.getText(); List<Book> result = searchBook(query);
resultArea.setText("");
if (result.size() > 0) {
for (Book book : result) { resultArea.append(book.toString() + "\n");
}
} else {
resultArea.setText("No results found.");
}
}
});
// Show frame frame.setVisible(true);
}
public static void main(String[] args) { Library library = new Library(); library.createGUI();
}
}
Conclusion and Future Work
This website provides a computerized version of the library management system which will
benefit the students as well as the staff of the library. It makes the entire process online where
students can search books, staff can generate reports and do book transactions. It also has a
facility for student login where students can login and can see the status of books issued as well
as request for books or give some suggestions. It has a facility of teacher’s login where teachers
can add lectures notes and also give necessary suggestions to the library and also add info about
workshops or events happening in our college or nearby college in the online notice board. There
is a future scope of this facility that many more features such as online lectures video tutorials
can be added by teachers as well as online assignments submission facility , a feature Of group
chat where students can discuss various issues of engineering can be added to this project thus
making it more interactive more user friendly and project which fulfills each users need in the
best way possible.
References
● http://www.w3schools.com/css/css_background.asp
● http://www.w3schools.com/sql/sql_update.asp
● https://www.w3schools.com/js/js_datatypes.asp
● Fundamentals of software engineering by Rajib mall, PHIlearning
● Web development and application development by Ivan Byross BPB publications

You might also like