You are on page 1of 135

Acknowledgement

I would like to thank my parents and friends who supported to complete this project
within the allocated time. I would also like to thank Mr. Dasun Sirimewan our lecturer
for giving us support to complete the project successfully. This assignment helped me
to get a good knowledge about Java language and designing a system using Java
language was a good experience for me.

Mohammed Basith Programming with Java 1


Contents

2 Task 1: Understand the principles of programming in Java...................................7

2.1 Discuss principals, characteristics and features relating to the Java


programming..............................................................................................................7

2.2 Critically evaluate JVM Environment and its Environmental flexibility in


building platform independent Java Programs.........................................................10

3 Task 2: Be able to design Java solutions..............................................................12

3.1 Design the given scenario using - UML Diagrams.......................................12

4 Task 3: Be able to implement Java solutions........................................................25

4.1 Implement an Object-Oriented solution for the given scenario using


NetBeans IDE...........................................................................................................25

4.2 Define relationships between objects to implement design requirements.....57

4.3 Explain control structures used in the solution with examples.....................65

4.4 Identify and implement opportunities for error handling and reporting........68

4.5 Provide the list of examples how you experienced user-friendliness of


Integrated Development Environment.....................................................................70

5 Task 4: Be able to test and document Java solutions............................................73

5.1 Provide suitable test plan to critically review and test the developed system.
73

5.2 Provide suitable test cases to analyze the expected test results against actual
outputs to identify discrepancies..............................................................................75

5.3 Evaluate independent feedback on your system..........................................106

5.4 Create user documentation for the developed java program solution.........108

5.5 Create a technical document........................................................................125

6 Appendix A.........................................................................................................131

6.1 Gantt chart...................................................................................................131

7 Appendix B.........................................................................................................133

7.1 Questionnaire...............................................................................................133

8 Reference............................................................................................................134

Mohammed Basith Programming with Java 2


List of Tables
Table 1 Attributes in user class....................................................................................57
Table 2 Methods in user class......................................................................................57
Table 3 Attributes of the member class........................................................................58
Table 4 Methods in member class................................................................................58
Table 5 Attributes of book class...................................................................................59
Table 6 Methods in book class.....................................................................................59
Table 7 Attributes of the nook return class..................................................................59
Table 8 Methods of the book return class....................................................................60
Table 9 Attributes of the book release class.................................................................60
Table 10 Methods of book release class......................................................................61
Table 11 Attributes of the payment class.....................................................................62
Table 12 Methods of the payment class.......................................................................62
Table 13 Attributes of the fine class............................................................................62
Table 14 Methods of the fine class..............................................................................62
Table 15 Test Plan for Librarian..................................................................................73
Table 16 Test Plan for member....................................................................................74
Table 17 Test Plan for super user.................................................................................74
Table 18 Login test case...............................................................................................76
Table 19 Add book test case........................................................................................76
Table 20 Update & remove book test case...................................................................77
Table 21 View & search book test case.......................................................................79
Table 22 Add member test case...................................................................................80
Table 23 Update & remove member test case.............................................................81
Table 24 View & search member test case..................................................................83
Table 25 data selection test case..................................................................................84
Table 26 Date relate functions test case.......................................................................85
Table 27 Book release & update test case....................................................................86
Table 28 Book return data selection test case..............................................................87
Table 29 Validation & remove released books test case..............................................89
Table 30 Add payment test case...................................................................................89
Table 31 Amount count function test case...................................................................90
Table 32 Validation & remove released books test case..............................................91
Table 33 Create account test case................................................................................92

Mohammed Basith Programming with Java 3


Table 34 Search & select record test case....................................................................93
Table 35 Remove accounts test case............................................................................93
Table 36 View fine test case........................................................................................94
Table 37 Search fines test case.....................................................................................95
Table 38 View & search books(member) test case......................................................97
Table 39 Book release data selection (member) test case............................................98
Table 40 Date related functions (member) test case....................................................99
Table 41 Validation & book release (member) test case...........................................100
Table 42 Update member details (member) test case................................................101
Table 43 Data selection in overdue (member) test case.............................................102
Table 44 date count function (member) test case.......................................................103
Table 45 Amount count function (member) test case................................................104
Table 46 Create & remove user accounts (super user) test case................................105
Table 47 Gantt Chart..................................................................................................131

Mohammed Basith Programming with Java 4


List of Figures
Figure 1 Use Case Diagram for Proposed System.......................................................12
Figure 2 Class Diagram................................................................................................15
Figure 3 Sequence Diagram.........................................................................................17
Figure 4 Activity Diagram for Super User...................................................................18
Figure 5 Activity Diagram for Librarian......................................................................19
Figure 6 Activity Diagram for Member.......................................................................20
Figure 7 ER Diagram for LMS....................................................................................21
Figure 8 Level 0 DFD Diagram...................................................................................23
Figure 9 Level 1 DFD Diagram...................................................................................24
Figure 10 Example method 1.......................................................................................63
Figure 11 Example method 2.......................................................................................63
Figure 12 Example for inheritance...............................................................................64
Figure 13 Example for aggregation..............................................................................64
Figure 14 Example for if-else structure.......................................................................65
Figure 15 Example for while loop...............................................................................66
Figure 16 Example for sequence structure...................................................................67
Figure 17 Example for try-catch block........................................................................69
Figure 18 Example for throws......................................................................................69
Figure 19 GUI builder..................................................................................................70
Figure 20 Project window............................................................................................71
Figure 21 Break point...................................................................................................71
Figure 22 NetBeans profiler.........................................................................................72
Figure 23 Configure JRE...........................................................................................111
Figure 24 Installing JRE.............................................................................................111
Figure 25 finishing installation..................................................................................111
Figure 26 WAMP select location...............................................................................112
Figure 27 Installing WAMP.......................................................................................112
Figure 28 Server configuration..................................................................................113
Figure 29 Installation finish.......................................................................................113
Figure 30 Execution folder.........................................................................................114
Figure 31 Login user interface...................................................................................115
Figure 32 Librarian main menu..................................................................................115
Figure 33 Book interface (librarian)..........................................................................116

Mohammed Basith Programming with Java 5


Figure 34 Member interface (librarian)......................................................................116
Figure 35 Book release interface (Librarian).............................................................117
Figure 36 Book Return (librarian)..............................................................................117
Figure 37 Payment interface (librarian).....................................................................118
Figure 38 New user interface (librarian)....................................................................119
Figure 39 Fine interface (librarian)............................................................................119
Figure 40 Help interface (librarian)...........................................................................120
Figure 41 Main menu (member)................................................................................120
Figure 42 Book interface (member)...........................................................................121
Figure 43 Book release interface (member)...............................................................121
Figure 44 Overdue interface (member)......................................................................122
Figure 45 Help interface (member)............................................................................122
Figure 46 Update user interface (member)................................................................123
Figure 47 Main menu (super user).............................................................................123
Figure 48 New user (super user)................................................................................124
Figure 49 Help interface (super user).........................................................................124
Figure 50 - Functions of the system...........................................................................125
Figure 51 - Questionnaire...........................................................................................133

Mohammed Basith Programming with Java 6


1 Task 1: Understand the principles of programming in Java
1.1 Discuss principals, characteristics and features relating to the Java
programming.

OOP stands for Object Oriented Programming. It refers to a type of computer


programming in which programmers define not only the data type of a data
structure, but also the types of operations that can be applied to the data
structure. In this way, the data structure becomes an object that includes
both data and functions. In addition, programmers can create relationships
between one object and another. Object oriented programming is the newest
programming language and it based on entities known as objects. These objects
are organized into classes, which allow individual objects to be group together.
Most modern programming languages including Java, C#, and PHP, are object-
oriented languages, and many older programming languages now have object
oriented versions.

Object
An object in an OOP concept refers to a specific type, or instance, of a class.
Each object has a structure similar to other objects in the class, but can be
assigned individual characteristics. An object can also call functions, or
methods, specific to that object.

Inheritance
In object oriented programming, inheritance is the concept that when
a class of objects is defined, any subclass that is defined can inherit the
definitions of one or more general classes. A class can be defined using another
class as a foundation. In object oriented programming terminology, one class
can inherit fields and methods from another. An object that inherits from
another is called a subclass, and the object it inherits from is called a superclass.
A subclass extends the superclass. This not only speeds up program
development; it also ensures an inherent validity to the defined subclass object.
This concept allows to programmers for creating applications easily because of
this concept programmer don`t want to create many classes.

Mohammed Basith Programming with Java 7


Polymorphism
Generally, the ability to appear in many forms. In object oriented programming,
polymorphism refers to a programming language's ability to process objects
differently depending on their data type or class. More specifically, it is the ability to
redefine methods for derived classes. For example, given a base class shape,
polymorphism enables the programmer to define different are a method for any
number of derived classes, such as circles, rectangles and triangles. No matter what
shape an object is, applying the area method to it will return the correct results.
Polymorphism is considered to be a requirement of any true object oriented
programming language.

Encapsulation
In programming, the process of combining elements to create a new entity. For
example, a procedure is a type of encapsulation because it combines a series of
computer instructions. Likewise, a complex data type, such as a record or class, relies
on encapsulation. Object oriented programming languages rely heavily on
encapsulation to create high level objects. Encapsulation is closely related
to abstraction and information hiding. As I said, encapsulation is the process of
wrapping internal data like functions and variables together. Encapsulation allows
many benefits to programmers when coding. Because of encapsulation concept,
programmers can be made read only or write only fields, A class can have total
control over what is stored in its fields and the users of a class do not know how the
class stores its data.

Abstraction
Abstraction is the act of representing essential features without including the
background details or explanations. In the software engineering, the abstraction
principle is used to reduce complexity and allow efficient design and implementation
of complex software systems. Abstraction is one of the most important principles in
object oriented software engineering and is closely related to several other important
concepts, including encapsulation, inheritance and polymorphism. Abstraction is
applied in the process of identifying objects to model the problem. It is the process of
reducing these objects to their essence such that only the necessary elements are

Mohammed Basith Programming with Java 8


represented. Abstraction defines an object in terms of its properties, functionality, and
interface.

Features of JAVA

 Simple
Java syntaxes are based on C++ language and it is easy to use and understand to
users. Java language modified with removing rarely used items like explicit
pointers, operator overloading and etc. And also, it includes the rich set of APIs.
Finally, we don’t waste our time to remove unreferenced object, because, java has
a garbage selection feature.it removes the above mentioned objects automatically.

 Platform independent
A platform is the hardware or software environment in which a program runs.
There are two types of platforms software based and hardware-based. Java
provides software based platform. The Java platform differs from most other
platforms in the sense that it is a software based platform that runs on the top of
other hardware based platforms. Java code can be run on multiple platforms e.g.
Windows, Linux, Sun Solaris, Mac/OS etc. Java code is compiled by the compiler
and converted into bytecode. This bytecode is a platform-independent code
because it can be run on multiple platforms. For example, we can introduce
WORA.

 Robust
Robust simply means strong. Java uses strong memory management. There is lack
of pointers that avoids security problem. There is automatic garbage collection in
java. There is exception handling and type checking mechanism in java. All these
points make java robust.

 Architectural Neutral
Architecture represents processor. A Language or Technology is said to be
Architectural neutral which can run on any available processors in the real world
without considering their development and compilation.

Mohammed Basith Programming with Java 9


1.2 Critically evaluate JVM Environment and its Environmental flexibility in
building platform independent Java Programs.

JVM is an abstract machine. It is a specification that provides runtime


environment in which java bytecode can be executed. JVMs are available for
many hardware and software platforms. Java is a platform independent
programming language. Therefore, JVM is the platform independent execution
engine. A Java virtual machine, an implementation of the Java Virtual Machine
Specification, interprets compiled Java binary code called bytecode for a
computer's processor  so that it can perform a Java program's instructions. Java
was designed to allow application programs to be built that could be run on
any platform without having to be rewritten or recompiled by the programmer
for each separate platform. A Java virtual machine makes this possible because
it is aware of the specific instruction lengths and other particularities of the
platform. The Java Virtual Machine Specification defines an abstract rather than
a real machine or processor. The Specification specifies an instruction set, a set
of registers, a stack, a garbage heap, and a method area. Once a Java virtual
machine has been implemented for a given platform, any Java program which,
after compilation, is called bytecode can run on that platform. A Java virtual
machine can either interpret the bytecode one instruction at a time or the
bytecode can be compiled further for the real processor using what is called
a just-in-time compiler.

JVM performs following instructions


o Loads code
o Verifies code
o Executes code
o Provides runtime environment

Java Virtual Machine is a single unit but it contains sub parts. Such as,
o Class Loader
o Class Area (Method Area)
o Stack and Heap

Mohammed Basith Programming with Java 10


o Program Counter Register
o Native Method Stack
o Execution Engine

Environmental flexibility in Java programming language.


A programming language or technology is said to be platform independent if and only
if which can run on all available operating systems with considering to its
development and compilation. Platform means Operating systems in here. Java is a
platform independent programming language, because when you install JDK software
on your system then automatically JVM are installed on your system. For every
operating system separate JVM is available which is capable to read the .class file
or byte code. When we compile your Java code then .class file is generated by java
compiler these codes are readable by JVM and every operating system have its own
JVM. So JVM is platform dependent but due to JVM java language is become
platform independent.

Java is operating system independent programming language. Because, when java is


compiling an English java file once into byte code called .class file, you will be able
to run it on Windows, Linux, OS X, BSD, various embedded operating systems. But
there are exceptions in this. Some GUI java applications will look similar but not
exactly the same on different OS to adapt to the native UI style.

Java is both compiler and interpreter language. When you compile a Java program it
creates .class file which is collection of byte code, this byte code is not machine
instruction instead they are instruction which Java virtual machine can understand.
Since every Java program runs on Java virtual machine, same byte code can be run on
any platform. key is byte code is not machine instruction they are platform
independent instruction to JVM.

Java programming language also hardware independent. In early years, and mostly in
the near and far future, there are so many different architectures for CPU. ARM, X86,
MIPS, etc. When compiling C code for different hardware, it means you compile for
all of these CPU. However, with Java, you, as an application developer, compile only
once. The work translating byte code to machine code is left to JVM writers. JVM
providers are responsible to write different Java runtime for different hardware. 

Mohammed Basith Programming with Java 11


2 Task 2: Be able to design Java solutions
2.1 Design the given scenario using - UML Diagrams
Use case Diagram

Mohammed Basith Programming with Java 12


Figure 1 Use Case Diagram for Proposed System

Use Case introduction


 Login use case - This use case represents the login function of the system. Using
this function librarian and standard member can access to the system.

Mohammed Basith Programming with Java 13


 Log Out use case - This represents the log out function. Librarian and standard
member can log out from system using this function.
 Add Member use case - This use case belongs to librarian only. Librarian can add
new members to the system through this function.
 Get Member Details use case - This use case is a part of Add Member use case.
Because, this use case is no point without Add Member use case. But librarian
also cannot perform Add Member function without this this. Therefore, I used
INCLUDE relationship between these 02 use cases.
 Create Login Credentials use case - This use case represents the new user
function. After adding new member to the system, librarian wants to give access
credentials to the newly added member. Therefore, librarian wants this function to
provide usernames and passwords to the new users.
 Add Books use case - This use case represents the add book function. Without this
function, librarian cannot add books to the system. This is a primary requirement
of this system.
 Search Members and Books - This use case represents to search functions of this
system. This use case belongs to librarian only. Because, standard user cannot
search other members’ details. But this function allows librarian to search all the
books and member details.
 Check Borrowed Book Details use case - This use case represents to search
member wise borrowed book details and view according to search functions.
Librarian and standard user can use these functions to get book borrowed details
from the system.
 Check Availability use case - Check availability use case is a sub use case of
Check Borrowed Book Details use case. Sometimes, the members either borrow
books or not. So, I used EXTEND relationship between these 02 use cases.
 Return Borrowed Books use cases - If member borrowed the books, member has a
responsibility to return those books on time. This use case represents the book
returning process of this system.
 Pay Fines use case - This use case represents the payments. If a member could not
return books on time, member wants to pay some fine for that. This use case also a
sub use case of Return Borrowed Book use case. Sometimes, the member either

Mohammed Basith Programming with Java 14


pay fines or not. Therefore, I used EXTEND relationship between these 02 use
cases.
 Manage Fines use case - This use case represents the fine managing process of the
system. Librarian wants to view all the fines details according to members.
 Check Overdue Book Details use case - This use case represents the overdue
sorting process of this system. Overdue details view to the librarian and standard
members when they log in to the system. Librarian can see all of the overdue
details and member can see own details only.
 Reserve Books use case - This use case represents the book releasing process of
this system. Librarian can reserve books for members and standard members can
reserve books for themselves.
 Cancel Reservation use case - This use case is a sub use case of Reserve Books
use case. Sometimes, user want to cancel book reservation process. At that
moment user can use this cancelling process. This cancelling process does not
need in every time. Therefore, I used EXTEND relationship between these 02 use
cases.
 Search Books use case - This use case represents the book search function.
Librarian and standard member can search and select existing books in the
database.

Class Diagram

Mohammed Basith Programming with Java 15


Figure 2 Class Diagram

Class Diagram Introduction

Mohammed Basith Programming with Java 16


 Class_Book
All the book related functions/methods I coded in this class. Such as, addBooks(),
updateBooks(), loadBookTable(). User can perform add, update, search and delete
books using these methods.

 Class_member
All the member related methods I coded in this class. There are 07 public methods
and 06 private variables in this class. User can add, update, search and delete
member details using these methods and variables.

 Class_User
All the user related methods I include into this class. User class mainly
responsible for converting members into users. As this system, every standard
member has a unique user name and password for login to the system.
Administrator or super user can create unique user names and passwords for
members using this class. This user class has 10 methods and 5 variables to
perform user related tasks properly.

 Class_Book_Release
Book release class controls all the book reserving process of this system. This
class has 16 methods and 08 variables to manage book reserving process. User can
get 02 books as this system and all the users can check books details and released
book details. Librarian can see all of the book released details and member can see
his or her details only.

 Class_Book_Return
Book return class has all the methods related to book returning process. Only
librarian can interact with these functions. Because, other users have not
privileges to interact with these functions. Book returning process is the very
important one because, payments are connecting with this process. In this book
return class have methods to count payments, dates and others.

Mohammed Basith Programming with Java 17


Sequence Diagram

Figure 3 Sequence Diagram

Mohammed Basith Programming with Java 18


Activity Diagram

Figure 4 Activity Diagram for Super User

Mohammed Basith Programming with Java 19


Figure 5 Activity Diagram for Librarian

Mohammed Basith Programming with Java 20


Figure 6 Activity Diagram for Member

Mohammed Basith Programming with Java 21


ER Diagram

Figure 7 ER Diagram for LMS

Mohammed Basith Programming with Java 22


ER Diagram Introduction

 tbl_member entity
This entity helps to store member details of the system, which means, even
librarian details are stored in this entity. This entity has 06 attributes. There is
member_id, member_name, member_address, member_contact, member_nic and
finally email. Among these attributes, member_id is a special one because, that
attribute has primary key constraint and auto increment facility.

 tbl_book entity
This entity helps to store book details of the system This entity has 05 attributes.
There is book_id, book_name, category, comment and finally author_name.
Among these attributes, book_id is a special one because, that attribute has
primary key constraint and auto increment facility.

 tbl_user entity
This entity helps to store user credentials of the system, which means, even
librarian details or super user credentials are stored in this entity. This entity has
05 attributes. There is user_id, member_name, user_access, password and finally
user_name. Among these attributes, user_id is a special one because, that attribute
has primary key constraint and auto increment facility.

 tbl_book_release entity
This entity helps to store released books and released date of the system. This
entity has 06 attributes. There is release_id, member_name, book1, book2,
release_date and finally return_date. Among these attributes, release_id is a
special one because, that attribute has primary key constraint and auto increment
facility.

 tbl_payment entity
This entity helps to store payment and fine details of the system. This entity has
06 attributes. There is payment_id, member_name, days, amount, release_date and
finally return_date. Among these attributes, payment_id is a special one because,
that attribute has primary key constraint and auto increment facility.

Mohammed Basith Programming with Java 23


Data flow diagram

Figure 8 Level 0 DFD Diagram

Mohammed Basith Programming with Java 24


Figure 9 Level 1 DFD Diagram

Mohammed Basith Programming with Java 25


3 Task 3: Be able to implement Java solutions
3.1 Implement an Object-Oriented solution for the given scenario using
NetBeans IDE.
 Class Book

public class CLASS_BOOKS extends DBConnection {

static Connection c;

static Statement s;

static DefaultTableModel dtm;

static ResultSet rs;

//Add Books to the System

public static void addBooks(String bname, String aname, String category, String comment)
{try {

c = DBConnection.getMyConnection();

s = c.createStatement();

s.executeUpdate("INSERT INTO tbl_books


(book_name,author_name,category,comment) VALUES('" + bname + "','" + aname + "','" +
category + "','" + comment + "')");

} catch (Exception ex) {

ex.printStackTrace();}}

//Load Books To table

public static void loadBookTable() {

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

dtm = (DefaultTableModel) LIBRARIAN_MAIN_MENU.Table_Books.getModel();

rs = s.executeQuery("SELECT * FROM tbl_books");

while (rs.next()) {

Vector v = new Vector();

v.add(rs.getString("book_name"));

v.add(rs.getString("author_name"));

v.add(rs.getString("category"));

v.add(rs.getString("comment"));

Mohammed Basith Programming with Java 26


dtm.addRow(v);

}} catch (Exception e) {

e.printStackTrace();}}

//load book ID according to selected row

public static void loadBookTable(String bname) {

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

rs = s.executeQuery("SELECT (book_id) FROM tbl_books WHERE "

+ "book_name='" + bname + "'");

int count = rs.last() ? rs.getRow() : 0;

System.out.println(count);

if (count == 1) {

LIBRARIAN_MAIN_MENU.ID.setText(rs.getString("book_id"));

}} catch (Exception e) {

e.printStackTrace();}}

// Update Book Details

public static void updateBooks(int id, String bname, String aname, String category, String
comment) {

try {c = DBConnection.getMyConnection();

s = c.createStatement();

s.executeUpdate("UPDATE tbl_books SET book_name='" + bname +


"',author_name='" + aname + "',category='" + category + "',comment='" + comment + "'
WHERE book_id='" + id + "'");

} catch (Exception ex) {

ex.printStackTrace()}}

//Search table according to book name

public static void searchBookName(String bname) {

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

dtm = (DefaultTableModel) LIBRARIAN_MAIN_MENU.Table_Books.getModel();

Mohammed Basith Programming with Java 27


rs = s.executeQuery("select * from tbl_books where book_name like '" + bname +
"%'");

dtm.setRowCount(0);

while (rs.next()) {

Vector v = new Vector();

v.add(rs.getString("book_name"));

v.add(rs.getString("author_name"));

v.add(rs.getString("category"));

v.add(rs.getString("comment"));

dtm.addRow(v);

}} catch (Exception e) {

e.printStackTrace();}}

//Search table according to Author name

public static void searchBookAuthor(String aname) {

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

dtm = (DefaultTableModel) LIBRARIAN_MAIN_MENU.Table_Books.getModel();

rs = s.executeQuery("select * from tbl_books where author_name like '" + aname +


"%'");

dtm.setRowCount(0);

while (rs.next()) {

Vector v = new Vector();

v.add(rs.getString("book_name"));

v.add(rs.getString("author_name"));

v.add(rs.getString("category"));

v.add(rs.getString("comment"));

dtm.addRow(v);

}} catch (Exception e) {

e.printStackTrace();}}

//Delete selected Book Details

public static void deleteBook(int id) {

Mohammed Basith Programming with Java 28


try {

c = DBConnection.getMyConnection();

s = c.createStatement();

s.executeUpdate("DELETE FROM tbl_books WHERE book_id='" + id + "'");

} catch (Exception ex) {

ex.printStackTrace();}}

//Load Books To table Member UI

public static void loadMemberBooks() {

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

dtm = (DefaultTableModel)
MEMBER_MAIN_MENU.Table_Member_Books.getModel();

rs = s.executeQuery("SELECT * FROM tbl_books");

while (rs.next()) {

Vector v = new Vector();

v.add(rs.getString("book_name"));

v.add(rs.getString("author_name"));

v.add(rs.getString("category"));

v.add(rs.getString("comment"));

dtm.addRow(v);

}} catch (Exception e) {

e.printStackTrace();}}

//Search table Member UI according to book name

public static void searchMemberBookName(String bname) {

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

dtm = (DefaultTableModel)
MEMBER_MAIN_MENU.Table_Member_Books.getModel();

rs = s.executeQuery("select * from tbl_books where book_name like '" + bname +


"%'");

Mohammed Basith Programming with Java 29


dtm.setRowCount(0);

while (rs.next()) {

Vector v = new Vector();

v.add(rs.getString("book_name"));

v.add(rs.getString("author_name"));

v.add(rs.getString("category"));

v.add(rs.getString("comment"));

dtm.addRow(v);

}} catch (Exception e) {

e.printStackTrace();}}

//Search table Member UI according to Author name

public static void searchMemberBookAuthor(String aname) {

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

dtm = (DefaultTableModel)
MEMBER_MAIN_MENU.Table_Member_Books.getModel();

rs = s.executeQuery("select * from tbl_books where author_name like '" + aname +


"%'");

dtm.setRowCount(0);

while (rs.next()) {

Vector v = new Vector();

v.add(rs.getString("book_name"));

v.add(rs.getString("author_name"));

v.add(rs.getString("category"));

v.add(rs.getString("comment"));

dtm.addRow(v);

}} catch (Exception e) {

e.printStackTrace();}}}

Mohammed Basith Programming with Java 30


 Class Book Release

public class CLASS_BOOK_RELEASE extends DBConnection{

static Connection c;

static Statement s;

static DefaultTableModel dtm;

static ResultSet rs;

//Load Member Details

public static void loadMemberTable() {

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

dtm = (DefaultTableModel)
LIBRARIAN_MAIN_MENU.Table_Release_Member.getModel();

rs = s.executeQuery("SELECT * FROM tbl_member");

while (rs.next()) {

Vector v = new Vector();

v.add(rs.getString("member_name"));

v.add(rs.getString("member_nic"));

dtm.addRow(v);

}} catch (Exception e) {

e.printStackTrace();}}

//Load Books To table

public static void loadBook1() {

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

dtm = (DefaultTableModel)
LIBRARIAN_MAIN_MENU.Table_Release_Book1.getModel();

rs = s.executeQuery("SELECT * FROM tbl_books");

while (rs.next()) {

Vector v = new Vector();

Mohammed Basith Programming with Java 31


v.add(rs.getString("book_name"));

v.add(rs.getString("author_name"));

dtm.addRow(v);

}} catch (Exception e) {

e.printStackTrace();}}

//Load Books To table

public static void loadBook2() {

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

dtm = (DefaultTableModel)
LIBRARIAN_MAIN_MENU.Table_Release_Book2.getModel();

rs = s.executeQuery("SELECT * FROM tbl_books");

while (rs.next()) {

Vector v = new Vector();

v.add(rs.getString("book_name"));

v.add(rs.getString("author_name"));

dtm.addRow(v);

}} catch (Exception e) {

e.printStackTrace();}}

//Search table according to book name

public static void searchBookName1(String bname){

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

dtm = (DefaultTableModel)
LIBRARIAN_MAIN_MENU.Table_Release_Book1.getModel();

rs = s.executeQuery("select * from tbl_books where book_name like '" + bname +


"%'");

dtm.setRowCount(0);

while (rs.next()) {

Vector v = new Vector();

Mohammed Basith Programming with Java 32


v.add(rs.getString("book_name"));

v.add(rs.getString("author_name"));

dtm.addRow(v);

}} catch (Exception e) {

e.printStackTrace();}}

//Search table according to book name

public static void searchBookName2(String bname){

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

dtm = (DefaultTableModel)
LIBRARIAN_MAIN_MENU.Table_Release_Book2.getModel();

rs = s.executeQuery("select * from tbl_books where book_name like '" + bname +


"%'");

dtm.setRowCount(0);

while (rs.next()) {

Vector v = new Vector();

v.add(rs.getString("book_name"));

v.add(rs.getString("author_name"));

dtm.addRow(v);

}} catch (Exception e) {

e.printStackTrace();}}

//Search table according to Member name

public static void searchMemberName(String mname){

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

dtm = (DefaultTableModel)
LIBRARIAN_MAIN_MENU.Table_Release_Member.getModel();

rs = s.executeQuery("select * from tbl_member where member_name like '" +


mname + "%'");

dtm.setRowCount(0);

while (rs.next()) {

Mohammed Basith Programming with Java 33


Vector v = new Vector();

v.add(rs.getString("member_name"));

v.add(rs.getString("member_nic"));

dtm.addRow(v);

}} catch (Exception e) {

e.printStackTrace();}}

//Release Books to the Members

public static void releaseBooks(String book1, String book2, String member, String
start_date,String end_date) {

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

s.executeUpdate("INSERT INTO tbl_book_release


(book1,book2,member_name,release_date,return_date) VALUES('" + book1 + "','" + book2 +
"','" + member + "','" + start_date + "','"+ end_date +"')");

} catch (Exception ex) {

ex.printStackTrace();}}

//Load Release Schedule To table

public static void loadReleaseBookTable() {

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

dtm = (DefaultTableModel)
LIBRARIAN_MAIN_MENU.Table_Release_Book_Schedule.getModel();

rs = s.executeQuery("SELECT * FROM tbl_book_release");

while (rs.next()) {

Vector v = new Vector();

v.add(rs.getString("book1"));

v.add(rs.getString("book2"));

v.add(rs.getString("member_name"));

v.add(rs.getString("release_date"));

v.add(rs.getString("return_date"));

Mohammed Basith Programming with Java 34


dtm.addRow(v);

}} catch (Exception e) {

e.printStackTrace();}}

// Update Schedule Details

public static void updateSchedule(int id,String book1,String book2,String member){

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

s.executeUpdate("UPDATE tbl_book_release SET book1='" + book1 + "',book2='" +


book2 + "',member_name='" + member + "' WHERE release_id='"+ id +"'");

} catch (Exception ex) {

ex.printStackTrace();}}

//load Schedule ID according to selected row

public static void loadScheduleID(String mname) {

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

rs = s.executeQuery("SELECT (release_id) FROM tbl_book_release WHERE


member_name='"+ mname +"'");

int count = rs.last() ? rs.getRow() : 0;

System.out.println(count);

if (count == 1) {

LIBRARIAN_MAIN_MENU.ID.setText(rs.getString("release_id"));

}} catch (Exception e) {

e.printStackTrace();}}

//Search table according to Member name

public static void searchSchedule(String mname){

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

dtm = (DefaultTableModel)
LIBRARIAN_MAIN_MENU.Table_Release_Book_Schedule.getModel();

Mohammed Basith Programming with Java 35


rs = s.executeQuery("select * from tbl_book_release where member_name like '" +
mname + "%'");

dtm.setRowCount(0);

while (rs.next()) {

Vector v = new Vector();

v.add(rs.getString("book1"));

v.add(rs.getString("book2"));

v.add(rs.getString("member_name"));

v.add(rs.getString("release_date"));

v.add(rs.getString("return_date"));

dtm.addRow(v);

}} catch (Exception e) {

e.printStackTrace();}}

//Load Books To table Member UI

public static void loadMemberBook1() {

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

dtm = (DefaultTableModel)
MEMBER_MAIN_MENU.Table_Book_Release1.getModel();

rs = s.executeQuery("SELECT * FROM tbl_books");

while (rs.next()) {

Vector v = new Vector();

v.add(rs.getString("book_name"));

v.add(rs.getString("author_name"));

dtm.addRow(v);

}} catch (Exception e) {

e.printStackTrace();}}

//Load Books To table Member UI

public static void loadMemberBook2() {

try {

c = DBConnection.getMyConnection();

Mohammed Basith Programming with Java 36


s = c.createStatement();

dtm = (DefaultTableModel)
MEMBER_MAIN_MENU.Table_Book_Release2.getModel();

rs = s.executeQuery("SELECT * FROM tbl_books");

while (rs.next()) {

Vector v = new Vector();

v.add(rs.getString("book_name"));

v.add(rs.getString("author_name"));

dtm.addRow(v);

}} catch (Exception e) {

e.printStackTrace();}}

//Search table according to book name

public static void searchMemberBookName1(String bname){

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

dtm = (DefaultTableModel)
MEMBER_MAIN_MENU.Table_Book_Release1.getModel();

rs = s.executeQuery("select * from tbl_books where book_name like '" + bname +


"%'");

dtm.setRowCount(0);

while (rs.next()) {

Vector v = new Vector();

v.add(rs.getString("book_name"));

v.add(rs.getString("author_name"));

dtm.addRow(v);

}} catch (Exception e) {

e.printStackTrace();}}

//Search table according to book name

public static void searchMemberBookName2(String bname){

try {

Mohammed Basith Programming with Java 37


c = DBConnection.getMyConnection();

s = c.createStatement();

dtm = (DefaultTableModel)
MEMBER_MAIN_MENU.Table_Book_Release2.getModel();

rs = s.executeQuery("select * from tbl_books where book_name like '" + bname +


"%'");

dtm.setRowCount(0);

while (rs.next()) {

Vector v = new Vector();

v.add(rs.getString("book_name"));

v.add(rs.getString("author_name"));

dtm.addRow(v);

}} catch (Exception e) {

e.printStackTrace();}}

//Load Release Schedule To table

public static void loadReleaseMemberBookTable(String mnane) {

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

dtm = (DefaultTableModel)
MEMBER_MAIN_MENU.Table_Release_Details.getModel();

rs = s.executeQuery("SELECT * FROM tbl_book_release WHERE


member_name='"+ mnane +"'");

while (rs.next()) {

Vector v = new Vector();

v.add(rs.getString("book1"));

v.add(rs.getString("book2"));

v.add(rs.getString("member_name"));

v.add(rs.getString("release_date"));

v.add(rs.getString("return_date"));

dtm.addRow(v);

}} catch (Exception e) {

e.printStackTrace();}}}

Mohammed Basith Programming with Java 38


 Class Book Return

public class CLASS_BOOK_RETURN extends DBConnection{

static Connection c;

static Statement s;

static DefaultTableModel dtm;

static ResultSet rs;

//Load Release Schedule To table

public static void loadReturnBookTable() {

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

dtm = (DefaultTableModel)
LIBRARIAN_MAIN_MENU.Table_Book_Return.getModel();

rs = s.executeQuery("SELECT * FROM tbl_book_release");

while (rs.next()) {

Vector v = new Vector();

v.add(rs.getString("member_name"));

v.add(rs.getString("book1"));

v.add(rs.getString("book2"));

v.add(rs.getString("release_date"));

v.add(rs.getString("return_date"));

dtm.addRow(v);

}} catch (Exception e) {

e.printStackTrace();}}

//Search table according to Member name

public static void searchMemberName(String mname) {

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

dtm = (DefaultTableModel)
LIBRARIAN_MAIN_MENU.Table_Book_Return.getModel();

Mohammed Basith Programming with Java 39


rs = s.executeQuery("select * from tbl_book_release where member_name like '" +
mname + "%'");

dtm.setRowCount(0);

while (rs.next()) {

Vector v = new Vector();

v.add(rs.getString("member_name"));

v.add(rs.getString("book1"));

v.add(rs.getString("book2"));

v.add(rs.getString("release_date"));

v.add(rs.getString("return_date"));

dtm.addRow(v);

}} catch (Exception e) {

e.printStackTrace();}}

//load Schedule ID according to selected row

public static void loadScheduleID(String mname) {

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

rs = s.executeQuery("SELECT (release_id) FROM tbl_book_release WHERE


member_name='"+ mname +"'");

int count = rs.last() ? rs.getRow() : 0;

System.out.println(count);

if (count == 1) {

LIBRARIAN_MAIN_MENU.ID.setText(rs.getString("release_id"));

}} catch (Exception e) {

e.printStackTrace();}}

//Delete selected Schedule Details

public static void deleteScedule(int id){

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

s.executeUpdate("DELETE FROM tbl_book_release WHERE release_id='"+ id +"'");

Mohammed Basith Programming with Java 40


} catch (Exception ex) {

ex.printStackTrace();}}

//Load Release Schedule To table

public static void loadMemberBookTable(String mname) {

try {c = DBConnection.getMyConnection();

s = c.createStatement();

dtm = (DefaultTableModel) MEMBER_MAIN_MENU.Table_Over_Due.getModel();

rs = s.executeQuery("SELECT * FROM tbl_book_release WHERE


member_name='"+ mname +"'");

while (rs.next()) {

Vector v = new Vector();

v.add(rs.getString("book1"));

v.add(rs.getString("book2"));

v.add(rs.getString("member_name"));

v.add(rs.getString("release_date"));

v.add(rs.getString("return_date"));

dtm.addRow(v);

}} catch (Exception e) {

e.printStackTrace();}}}

Mohammed Basith Programming with Java 41


 Class Fines

public class CLASS_FINES extends DBConnection{

static Connection c;

static Statement s;

static DefaultTableModel dtm;

static ResultSet rs;

//Load Fine Details

public static void loadFinesTable() {

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

dtm = (DefaultTableModel) LIBRARIAN_MAIN_MENU.Table_Fines.getModel();

rs = s.executeQuery("SELECT * FROM tbl_payment");

while (rs.next()) {

Vector v = new Vector();

v.add(rs.getString("member_name"));

v.add(rs.getString("release_date"));

v.add(rs.getString("return_date"));

v.add(rs.getString("days"));

v.add(rs.getString("amount"));

dtm.addRow(v);

}} catch (Exception e) {

e.printStackTrace();}}

//Search table according to Member name

public static void searchMemberName(String mname) {

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

dtm = (DefaultTableModel) LIBRARIAN_MAIN_MENU.Table_Fines.getModel();

rs = s.executeQuery("select * from tbl_payment where member_name like '" + mname


+ "%'");

Mohammed Basith Programming with Java 42


dtm.setRowCount(0);

while (rs.next()) {

Vector v = new Vector();

v.add(rs.getString("member_name"));

v.add(rs.getString("release_date"));

v.add(rs.getString("return_date"));

v.add(rs.getString("days"));

v.add(rs.getString("amount"));

dtm.addRow(v);

}} catch (Exception e) {

e.printStackTrace();}}}

Mohammed Basith Programming with Java 43


 Class Member

public class CLASS_MEMBER extends DBConnection{

static Connection c;

static Statement s;

static DefaultTableModel dtm;

static ResultSet rs;

//Add Members to the System

public static void addMember(String mname, String maddress, String mnic, String
mcontact, String mail) {

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

s.executeUpdate("INSERT INTO tbl_member


(member_name,member_address,member_nic,member_contact,email) VALUES('" + mname
+ "','" + maddress + "','" + mnic + "','" + mcontact + "','" + mail + "')");

} catch (Exception ex) {

ex.printStackTrace();}}

//Load Member Details

public static void loadMemberTable() {

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

dtm = (DefaultTableModel)
LIBRARIAN_MAIN_MENU.Table_Member.getModel();

rs = s.executeQuery("SELECT * FROM tbl_member");

while (rs.next()) {

Vector v = new Vector();

v.add(rs.getString("member_name"));

v.add(rs.getString("member_address"));

v.add(rs.getString("member_nic"));

v.add(rs.getString("member_contact"));

v.add(rs.getString("email"));

Mohammed Basith Programming with Java 44


dtm.addRow(v);

}} catch (Exception e) {

e.printStackTrace();}}

//load Member ID according to selected row

public static void loadMemberID(String mname) {

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

rs = s.executeQuery("SELECT (member_id) FROM tbl_member WHERE


member_name='" + mname + "'");

int count = rs.last() ? rs.getRow() : 0;

if (count == 1) {

LIBRARIAN_MAIN_MENU.ID.setText(rs.getString("member_id"));

}} catch (Exception e) {

e.printStackTrace();}}

//Update Member Details

public static void updateMember(int id, String mname, String maddress, String mnic,
String mcontact, String mail) {

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

s.executeUpdate("UPDATE tbl_member SET member_name='" + mname +


"',member_address='" + maddress + "',member_nic='" + mnic + "',member_contact='" +
mcontact + "',email='" + mail + "' WHERE member_id='" + id + "'");

} catch (Exception ex) {

ex.printStackTrace();}}

//Search table according to Member name

public static void searchMemberName(String mname) {

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

dtm = (DefaultTableModel)
LIBRARIAN_MAIN_MENU.Table_Member.getModel();

Mohammed Basith Programming with Java 45


rs = s.executeQuery("select * from tbl_member where member_name like '" + mname
+ "%'");

dtm.setRowCount(0);

while (rs.next()) {

Vector v = new Vector();

v.add(rs.getString("member_name"));

v.add(rs.getString("member_address"));

v.add(rs.getString("member_nic"));

v.add(rs.getString("member_contact"));

v.add(rs.getString("email"));

dtm.addRow(v);

}} catch (Exception e) {

e.printStackTrace();}}

//Search table according to Member NIC

public static void searchMemberNIC(String nic) {

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

dtm = (DefaultTableModel)
LIBRARIAN_MAIN_MENU.Table_Member.getModel();

rs = s.executeQuery("select * from tbl_member where member_nic like '" + nic +


"%'");

dtm.setRowCount(0);

while (rs.next()) {

Vector v = new Vector();

v.add(rs.getString("member_name"));

v.add(rs.getString("member_address"));

v.add(rs.getString("member_nic"));

v.add(rs.getString("member_contact"));

v.add(rs.getString("email"));

dtm.addRow(v);

}} catch (Exception e) {

Mohammed Basith Programming with Java 46


e.printStackTrace();}}

//Delete selected Member Details

public static void deleteMember(int id) {

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

s.executeUpdate("DELETE FROM tbl_member WHERE member_id='" + id + "'");

} catch (Exception ex) {

ex.printStackTrace();}}}

Mohammed Basith Programming with Java 47


 Class Payment
public class CLASS_PAYMENT extends DBConnection{

static Connection c;

static Statement s;

// Calculate fines

public static void fineAmount(){

int day_fine = 5;

int days = Integer.parseInt(PAYMENT.Txt_Payment_days.getText());

int fine;

if("".equals(LIBRARIAN_MAIN_MENU.Txt_Book_Return_Book1.getText()) &&
"".equals(LIBRARIAN_MAIN_MENU.Txt_Book_Return_Book2.getText())){

JOptionPane.showMessageDialog(null, "YOU HAVE TO SELECT ATLEAST 1


BOOK", "ERROR ALERT", JOptionPane.ERROR_MESSAGE);

}else if(!"".equals(LIBRARIAN_MAIN_MENU.Txt_Book_Return_Book1.getText())
&& !"".equals(LIBRARIAN_MAIN_MENU.Txt_Book_Return_Book2.getText())){

fine = (day_fine * days) * 2 ;

PAYMENT.Txt_Payment_Fine_Amount.setText(String.valueOf(fine));

}else if("".equals(LIBRARIAN_MAIN_MENU.Txt_Book_Return_Book2.getText())){

fine = day_fine * days;

PAYMENT.Txt_Payment_Fine_Amount.setText(String.valueOf(fine));

}else if("".equals(LIBRARIAN_MAIN_MENU.Txt_Book_Return_Book1.getText())){

fine = day_fine * days;

PAYMENT.Txt_Payment_Fine_Amount.setText(String.valueOf(fine));}}

//Add payment details to the system

public static void addPayment(String name, String release_date, String return_date, int
days, int amount){

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

s.executeUpdate("INSERT INTO tbl_payment


(member_name,release_date,return_date,days,amount) VALUES('" + name + "','" +
release_date + "','" + return_date + "','" + days + "','" + amount + "')");

} catch (Exception ex) {


ex.printStackTrace();}}}

Mohammed Basith Programming with Java 48


 Class user

public class CLASS_USER extends DBConnection{

static Connection c;

static Statement s;

static DefaultTableModel dtm;

static ResultSet rs;

//Check Login Credentials and Give permissions to access

public static String loginFunction(String user, String pass) {

String status = "NOT";

String access = "";

String member_name;

String user_name;

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

ResultSet rs = s.executeQuery("SELECT * FROM tbl_user WHERE user_name='" +


user + "' AND password='" + pass + "'");

int count = rs.last() ? rs.getRow() : 0;

//System.out.println(count);

if (count == 1) {

access = rs.getString("user_access");

JOptionPane.showMessageDialog(null, "Logged as :" + access, "LOGIN ALERT",


JOptionPane.INFORMATION_MESSAGE);

if ("Administrator".equals(access)) {

new SUPER_USER_MENU().setVisible(true);

member_name = rs.getString("user_name");

SUPER_USER_MENU.LBL_User.setText(member_name);

status = "OK";

} else if ("Member".equals(access)) {

new MEMBER_MAIN_MENU().setVisible(true);

status = "OK";

Mohammed Basith Programming with Java 49


user_name = rs.getString("user_name");

MEMBER_MAIN_MENU.LBL_User.setText(user_name);

member_name = rs.getString("member_name");

MEMBER_MAIN_MENU.Txt_Book_Release_Member.setText(member_name);

MEMBER_MAIN_MENU.ID.setText(member_name);

} else if ("Librarian".equals(access)) {

new LIBRARIAN_MAIN_MENU().setVisible(true);

member_name = rs.getString("user_name");

LIBRARIAN_MAIN_MENU.LBL_User.setText(member_name);

status = "OK";}

} else {

JOptionPane.showMessageDialog(null, "CHECK YOUR CREDENTIALS...!",


"LOGIN ALERT", JOptionPane.ERROR_MESSAGE);

}} catch (Exception e) {

e.printStackTrace();}

return status;}

//Load Member Details

public static void loadMemberTable() {

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

dtm = (DefaultTableModel)
LIBRARIAN_MAIN_MENU.Table_User_Member.getModel();

rs = s.executeQuery("SELECT * FROM tbl_member");

while (rs.next()) {

Vector v = new Vector();

Vector v1 = new Vector();

v.add(rs.getString("member_name"));

v.add(rs.getString("member_nic"));

dtm.addRow(v);

}} catch (Exception e) {

e.printStackTrace();}}

Mohammed Basith Programming with Java 50


//Search table according to Member name

public static void searchMemberName(String mname) {

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

dtm = (DefaultTableModel)
LIBRARIAN_MAIN_MENU.Table_User_Member.getModel();

rs = s.executeQuery("select * from tbl_member where member_name like '" +


mname + "%'");

dtm.setRowCount(0);

while (rs.next()) {

Vector v = new Vector();

v.add(rs.getString("member_name"));

v.add(rs.getString("member_nic"));

dtm.addRow(v);

}} catch (Exception e) {

e.printStackTrace();}}

//Add users to the System

public static void addUsers(String mname, String user, String pass, String access) {

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

s.executeUpdate("INSERT INTO tbl_user


(member_name,user_name,password,user_access) VALUES('" + mname + "','" + user + "','"
+ pass + "','" + access + "')");

} catch (Exception ex) {

ex.printStackTrace();}}

//Load Member Details

public static void loadUserTable() {

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

dtm = (DefaultTableModel) LIBRARIAN_MAIN_MENU.Table_User.getModel();

Mohammed Basith Programming with Java 51


rs = s.executeQuery("SELECT * FROM tbl_user");

while (rs.next()) {

Vector v = new Vector();

v.add(rs.getString("member_name"));

v.add(rs.getString("user_name"));

v.add(rs.getString("user_access"));

dtm.addRow(v);

}} catch (Exception e) {

e.printStackTrace();}}

//load User ID according to selected row

public static void loadUserID(String mname) {

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

rs = s.executeQuery("SELECT (user_id) FROM tbl_user WHERE member_name='"


+ mname + "'");

int count = rs.last() ? rs.getRow() : 0;

System.out.println(count);

if (count == 1) {

LIBRARIAN_MAIN_MENU.ID.setText(rs.getString("user_id"));

}} catch (Exception e) {

e.printStackTrace();}}

// Update User Details

public static void updateUser(int id, String mname, String user, String pass, String access)
{

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

s.executeUpdate("UPDATE tbl_user SET member_name='" + mname +


"',user_name='" + user + "',password='" + pass + "',user_access='" + access + "' WHERE
user_id='" + id + "'");

} catch (Exception ex) {

ex.printStackTrace();}}

Mohammed Basith Programming with Java 52


//Search table according to Member name

public static void searchUserName(String mname) {

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

dtm = (DefaultTableModel) LIBRARIAN_MAIN_MENU.Table_User.getModel();

rs = s.executeQuery("select * from tbl_user where member_name like '" + mname +


"%'");

dtm.setRowCount(0);

while (rs.next()) {

Vector v = new Vector();

v.add(rs.getString("member_name"));

v.add(rs.getString("user_name"));

v.add(rs.getString("user_access"));

dtm.addRow(v);

}} catch (Exception e) {

e.printStackTrace();}}

//Search table according to NIC

public static void searchUser(String user) {

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

dtm = (DefaultTableModel) LIBRARIAN_MAIN_MENU.Table_User.getModel();

rs = s.executeQuery("select * from tbl_user where user_name like '" + user + "%'");

dtm.setRowCount(0);

while (rs.next()) {

Vector v = new Vector();

v.add(rs.getString("member_name"));

v.add(rs.getString("user_name"));

v.add(rs.getString("user_access"));

dtm.addRow(v);}

Mohammed Basith Programming with Java 53


} catch (Exception e) {

e.printStackTrace();}}

//Delete selected user Details

public static void deleteUser(int id) {

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

s.executeUpdate("DELETE FROM tbl_user WHERE user_id='" + id + "'");

} catch (Exception ex) {

ex.printStackTrace();}}

//Load Member Details

public static void loadSuperUserTable() {

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

dtm = (DefaultTableModel) SUPER_USER_MENU.Table_User.getModel();

rs = s.executeQuery("SELECT * FROM tbl_user");

while (rs.next()) {

Vector v = new Vector();

Vector v1 = new Vector();

v.add(rs.getString("member_name"));

v.add(rs.getString("user_name"));

v.add(rs.getString("user_access"));

dtm.addRow(v);

}} catch (Exception e) {

e.printStackTrace();}}

//Load Member Details

public static void loadSuperMemberTable() {

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

Mohammed Basith Programming with Java 54


dtm = (DefaultTableModel)
SUPER_USER_MENU.Table_User_Member.getModel();

rs = s.executeQuery("SELECT * FROM tbl_member");

while (rs.next()) {

Vector v = new Vector();

Vector v1 = new Vector();

v.add(rs.getString("member_name"));

v.add(rs.getString("member_nic"));

dtm.addRow(v);

} catch (Exception e) {

e.printStackTrace();}}

//Search table according to Member name

public static void searchSuperMemberName(String mname) {

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

dtm = (DefaultTableModel)
SUPER_USER_MENU.Table_User_Member.getModel();

rs = s.executeQuery("select * from tbl_member where member_name like '" +


mname + "%'");

dtm.setRowCount(0);

while (rs.next()) {

Vector v = new Vector();

v.add(rs.getString("member_name"));

v.add(rs.getString("member_nic"));

dtm.addRow(v);

}} catch (Exception e) {

e.printStackTrace();}}

//load User ID according to selected row

public static void loadSuperUserID(String mname) {

try {

Mohammed Basith Programming with Java 55


c = DBConnection.getMyConnection();

s = c.createStatement();

rs = s.executeQuery("SELECT (user_id) FROM tbl_user WHERE member_name='"


+ mname + "'");

int count = rs.last() ? rs.getRow() : 0;

System.out.println(count);

if (count == 1) {

SUPER_USER_MENU.ID.setText(rs.getString("user_id"));

}} catch (Exception e) {

e.printStackTrace();}}

// Update User Details

public static void updateMemberUser(int id, String mname, String user, String pass) {

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

s.executeUpdate("UPDATE tbl_user SET member_name='" + mname +


"',user_name='" + user + "',password='" + pass + "' WHERE user_id='" + id + "'");

} catch (Exception ex) {

ex.printStackTrace();}}

//Load Release Schedule To table

public static void loadMemberUserTable(String mnane) {

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

dtm = (DefaultTableModel) MEMBER_MAIN_MENU.Table_User.getModel();

rs = s.executeQuery("SELECT * FROM tbl_user WHERE member_name='" +


mnane + "'");

while (rs.next()) {

Vector v = new Vector();

v.add(rs.getString("member_name"));

v.add(rs.getString("user_name"));

v.add(rs.getString("user_access"));

Mohammed Basith Programming with Java 56


dtm.addRow(v);

}} catch (Exception e) {

e.printStackTrace();}}

//load User ID according to selected row

public static void loadMemberUserID(String mname) {

try {

c = DBConnection.getMyConnection();

s = c.createStatement();

rs = s.executeQuery("SELECT (user_id) FROM tbl_user WHERE member_name='"


+ mname + "'");

int count = rs.last() ? rs.getRow() : 0;

System.out.println(count);

if (count == 1) {

MEMBER_MAIN_MENU.ID2.setText(rs.getString("user_id"));

}} catch (Exception e) {

e.printStackTrace();}}}

Mohammed Basith Programming with Java 57


3.2 Define relationships between objects to implement design requirements.
1. Object name - User
Attributes
Attribute
Type Description
name
-id Int This variable used to get id from database.
-mname String This variable used to store user inputted member name
-user String Store parsed username.
-pass String Store parsed password.
-access String This variable used to store selected access level
Table 1 Attributes in user class

Methods
Method Name Type Description
+loginFunction(user,pass) void Check user name and password.
+loadMemberTable() void Load member details.
+searchMemberName(mname) void Search member according to name.
+addUsers(mname,user,pass, void Add user to the system.
access)
+loadUserTable() void Load user details.
+updateUser(id,mname,user,pass, void Update user details.
access)
+loadUserID(mname) void Load id according to member name.
+searchUserName(mname) void Search user according to member.
+searchUser(user) void Search user according to user name.
+deleteUser(id) void Delete users.
+loadSuperUserTable() void Load user in super user interface.
+loadSuperMemberTable() void Load member details in super user
interface.
+searchSuperMemberName(mna void Member search according to member.
me)
+loadSuperUserID(mname) void Load member id according to member.
+updateMemberUser(id,mname, void Update member details.
user,pass)
+loadMemberUserID(mname) void Load user id according to user name
Table 2 Methods in user class

Mohammed Basith Programming with Java 58


1. Member

Attributes

Attribute
Type Description
name
-id Int This variable used to get id from database.
This variable used to store user inputted member
-mname String
name.
-maddress String This variable used to store user inputted address.
-mnic String This variable used to store user inputted nic
-mcontact String This variable used to store user inputted contact no.
This variable used to store user inputted email
-mail String
address.
Table 3 Attributes of the member class

Methods

Method Name Type Description

+addMember(mname,maddress void Insert member details to the


,mnic,mcontact,mail) system.
+loadMemberTable() void Load member details.
+searchMemberName(mname) void Search member according to
name.
+searchMemberNIC(mnic) void Search member according to
nic.
+deleteMember(id) void Delete member details.
+updateMember(id,mname,maddress, void Update user details.
mnic,mcontact,mail)
+loadMemberID(mname) void Load id according to member
name.
Table 4 Methods in member class

Mohammed Basith Programming with Java 59


2. Book
Attributes
Attribute
Type Description
name
-id Int This variable used to get id from database.
-bname String This variable used to store user inputted book name.
-aname String This variable used to store user inputted author.
-category String This variable used to store user selected category.
-comment String This variable used to store user inputted comment.
Table 5 Attributes of book class

Methods
Method Name Type Description

+addBooks(bname,aname, void Insert book details to the system.


category ,comment)
loadBookTable() void Load book details.
+searchBookName(bname) void Search book according to name.
+searchBookAuthor(aname) void Search book according to author.
+deleteBook(id) void Delete member details.
+updateBooks(id,bname,aname, void Update book details.
category,comment)
loadBookTable(bname) void Load id according to book name.
loadMemberBooks() void Load books in member interface.
+searchMemberBookName(bname) void Search book according to name.
+searchMemberBookAuthor(aname) void Search book according to author.
Table 6 Methods in book class

3. Book Return
Attributes
Attribute
Type Description
name
-id Int This variable used to get id from database.
-mname String This variable used to store parsed member name.
Table 7 Attributes of the nook return class

Mohammed Basith Programming with Java 60


Methods

Method Name Type Description

+loadReturnBookTable() void Load released book details.


+loadScheduleID(mname) void Load id according to member
+searchMemberName(mname) void Search record according to
member.
+loadMemberBookTable(mname) void Load record according to
member.
+deleteScedule(id) void Delete records
Table 8 Methods of the book return class

4. Book Release

Attributes

Attribute
Type Description
name
-id Int This variable used to get id from database.
-book1 String This variable used to store selected book 1.
-book2 String This variable used to store selected book 2.
-member String This variable used to store selected member.
-start_date String This variable used to store released date.
-end_date String This variable used to store return date.
-mname String This variable used to parse member name.
-bnane String This variable used to parse book name.
Table 9 Attributes of the book release class

Mohammed Basith Programming with Java 61


Methods

Method Name Type Description

+loadMemberTable() void Load member details.


+loadBook1() void Load book details.
+loadBook2() void Load book details.
+searchBookName1(bname) void Search book according to name.
+searchBookName2(bname) void Search book according to name.
+searchMemberName(mname) void Search member according to
name.
+releaseBooks(book1,book2, void Insert released book details.
member,start_date,end_date)
+loadReleaseBookTable() void Load released books.
+updateSchedule(id,book1,book2, void Update released book details.
member)
+loadScheduleID(mname) void Load id according to member
name.
+searchSchedule(mname) void Search according to member
name.
+loadMemberBook1() void Load book details in member
UI.
+loadMemberBook2() void Load book details in member
UI.
+searchMemberBookName1(bname) void Search book 1 according to
name.
+searchMemberBookName2(bname) void Search book 3 according to
name.
+loadReleaseMemberBookTable( void Load record according to
mname) member.
Table 10 Methods of book release class

Mohammed Basith Programming with Java 62


5. Payment

Attributes

Attribute
Type Description
name
-name int This variable used to get id from database.
-release_date String This variable used to store selected book 1.
-return_date String This variable used to store selected book 2.
-days int This variable used to store selected member.
-amount int This variable used to store released date.
Table 11 Attributes of the payment class

Methods

Method Name Type Description

+fineAmount() void Calculate fines.


+addPayment(name,release_date, void Insert payments to the system.
return_date,days,amount)
Table 12 Methods of the payment class

6. Fines

Attributes

Attribute
Type Description
name
-mname String This variable used to store parsed member name.
Table 13 Attributes of the fine class

Methods

Method Name Type Description

+loadFinesTable() void Load fine details


+searchMemberName(mname) void Search fines according to
member.
Table 14 Methods of the fine class

Mohammed Basith Programming with Java 63


Polymorphism
polymorphism refers to a programming language's ability to process objects
differently depending on their data type or class. In this situation, I created the
methods with same name and parameter list is different from each other. In
programming, we introduce this situation as the method over loading. If these
functions have same name, it is doing a various task.

Figure 10 Example method 1

Figure 11 Example method 2

Mohammed Basith Programming with Java 64


Inheritance
Inheritance concept explains the binding between two or more classes. If we have an
important code which wants to every other code, we can code it in a special way. We
can code that special code in a class and we can use the same code in every place that
the code needs. This concept introduced as the inheritance in programming. I also, use
this concept. In my software, I wanted to use database connection for every method.
Therefore, I wrote in a class and inherit that class in other classes. For inherit a class,
we can use extends keyword.

Figure 12 Example for inheritance

Encapsulation
Encapsulation is a OOP concept that describes the whole thing have created with
small parts. For example, we can get a java class. Java class is full object but it has
may be many code or not. But if we want to use encapsulation concept, we have to
use java classes definitely. Because of java class, we can divide our code pleasantly
and we categorize them. For example, I used 07 classes and I categorized methods
and variables into them. Now I can explain and new programmer can easily identify
the code in software. Above mentioned tables prove this concept generally.

Aggregation
If a class have an entity reference, it is known as Aggregation. Aggregation represents
HAS-A relationship. In this situation, we can use the components in another class
without staying that class. I used aggregation in my software. I wanted to parse details
to another class, when was running the other class. First of all, I import the class
which want to parse data to the first running class and call that component through
object.

Figure 13 Example for aggregation

Mohammed Basith Programming with Java 65


3.3 Explain control structures used in the solution with examples.
In programming, we can see the 03 kind of control structures. There are
sequential, selection and iteration. Control structure shows the program flow
and without those, we can`t create software. Any kind of control structure has
various notations or symbols to show program flow. Rectangle, parallelogram,
circle, diamond and lines with arrow heads are the basic symbols of this. In this
situation, we use rectangle for showing some kind of process like equations,
function callings. We can use parallelogram for showing input and output
operations. Circles for connecting few lines and we use diamond for showing
decisions and arrow headed lines show the program flow between notations.

Selection Control Structure


Selection control structure describes about decisions making. Decision making
by a computer is based on the same two step process. In java, decisions are
made with the if statement, also known as the selection statement. When
processing an if statement, the computer first evaluates some criterion or
condition. If it is met, the specified action is performed.  If the conditional
expression is true, the statements between the keywords THEN and ELSE will
be executed.  If the conditional expression is false, the statements between the
keywords ELSE and END If will be executed. Following is the structure of if
else condition.
IF (condition) {
} ELSE {
}

Following is the code example for if else condition.

Figure 14 Example for if-else structure

Mohammed Basith Programming with Java 66


When the situation arises where you need to choose between more than two
alternatives, we can use an extended form of the selection structure. That is switch
case structure.

Following is the structure of switch case.

SWITCH (expression) {
CASE constant expression 1:
statements;
break;
CASE constant expression 2:
statements;
break; }

Iteration Control Structure


Iteration control structure is a process which a set of instructions are repeated in a
sequence a specified number of times. When the first set of instructions is executed
again, it is called an iteration. In this situation, we can introduce this as looping. In
iteration structure, we can see 03 types of loops or iterations. There are while loop,
do-while loop, foreach loop and for loop. We can use while loop structure when we
want to repeat statements an indefinite number of times, until condition is true. If the
condition false, while loop stops it`s works and program compiler come to end/close
brace of the while loop. Following is the structure of while loop

WHILE (condition) {
statements
}

Following is the code example for while loop.

Figure 15 Example for while loop

Mohammed Basith Programming with Java 67


Do-while is another loop which repeat statements until its condition satisfy. This loop
most like while loop but do-while loop has a different. In while loop, if the condition
is false, the loop will be terminated. In that situation, we cannot get results through
while loop. But in do-while, we can get result at least one time. Because in this
situation, program compiler runs statements before check the condition. Following is
the structure of do-while loop.
DO {
} WHILE (condition);

For loop is the last loop in iteration control structure. We can create conditions,
variable declaration and initialization and increment and decrement operations in
parenthesis. In while loop and do-while loop, we can insert condition only. But in for
loop we can insert many. This is the difference between while and for loops.
Following is the structure of for loop.

FOR (start expression; condition; count expression) {


Block of codes
}

Sequence Control Structure


Sequence control structure is a control structure like a single line. It is deferent from
other two control structures. In this control structure, we can`t use any iteration or
selection. The sequence structure indicates instructions are to be executed one
statement at a time in the order they occur from top to bottom unless a different
control structure dictates otherwise. Following is the code example for sequence
structure.

Figure 16 Example for sequence structure

Mohammed Basith Programming with Java 68


3.4 Identify and implement opportunities for error handling and reporting.
Error handling refers to the anticipation, detection, and resolution of
programming, application, and communications errors. In programming, a
development error is one that can be prevented. Such an error can occur
in syntax or logic. Syntax errors, which are typographical mistakes or improper
use of special characters, are handled by rigorous proofreading. Logic errors,
also called bugs, occur when executed code does not produce the expected or
desired result. Logic errors are best handled by meticulous program debugging.

A run-time error takes place during the execution of a program, and usually
happens because of adverse system parameters or invalid input data.

Try catch block


"Try" and "catch" are keywords that represent the handling of exceptions due to
data or coding errors during program execution. A try block is the block of code
in which exceptions occur. A catch block catches and handles try block
exceptions. The try/catch statement is used in many programming languages,
including C programming language (C++ and C#), Java, JavaScript and
Structured Query Language (SQL).

Try defines a block of statements that may throw an exception. When a specific
type of exception occurs, a catch block catches the exception. If an exception is
not handled by try/catch blocks, the exception escalates through the call stack
until the exception is caught or an error message is printed by the compiler. A
try/catch block also may be nested with one or more try/catch statements. Each
try statement has a matching catch statement to handle the exception. If an
exception's inner try statement does not have a matching catch statement,
subsequent try statement catch handlers are checked. This process continues
until all inner try statements are checked for a matching catch statement. If a
catch statement does not match, the runtime system handles the exception.
Following is the structure of try catch block.

try {
} catch (Exception e) {
}

Mohammed Basith Programming with Java 69


Following is the code example for try catch block.

Figure 17 Example for try-catch block

When we are using try catch block, we can add another part to the block called
finally. ‘finally’ part adds to end of the catch and we can add statement, conditions or
anything like that to this finally block.

try {
} catch(Exception) {
} finally {}

Throwing an exception
In this situation, I have to use ‘throws’ key word. The Java throws keyword is used to
declare an exception. It gives an information to the programmer that there may occur
an exception so it is better for the programmer to provide the exception handling code
so that normal flow can be maintained. Exception Handling is mainly used to handle
the checked exceptions. If there occurs any unchecked exception such as
NullPointerException, it is programmers fault that he is not performing checkup
before the code being used. Following is the code example for throws key word.

Figure 18 Example for throws

Mohammed Basith Programming with Java 70


3.5 Provide the list of examples how you experienced user-friendliness of
Integrated Development Environment.
o Fast & Smart Code Editing
An IDE is much more than a text editor. The NetBeans Editor indents
lines, matches words and brackets, and highlights source code
syntactically and semantically. It lets you easily refactor code, with a range
of handy and powerful tools, while it also provides code templates, coding
tips, and code generators. And also, we have to consider color schemes of
the NetBeans IDE. Because, these color codes are giving programmers to
attractive and cool feeling. It is very hard to stay long time with coding
without suitable color coding scheme. NetBeans IDE has 02 main
background color schemes. Such as, light and dark. User can change this
color scheme as the user wish.

o Rapid User Interface Development


Design GUIs for Java SE, HTML5, Java EE, PHP, C/C++, and Java ME
applications quickly and smoothly by using editors and drag and drop tools
in the IDE. For Java SE applications, the NetBeans GUI Builder
automatically takes care of correct spacing and alignment, while
supporting in place editing, as well. 

Figure 19 GUI builder

Mohammed Basith Programming with Java 71


 Easy & Efficient Project Management
Keeping a clear overview of large applications, with thousands of folders and
files, and millions of lines of code, is a daunting task. NetBeans IDE provides
different views of your data, from multiple project windows to helpful tools for
setting up your applications and managing them efficiently. When new developers
join your project, they can understand the structure of your application because
your code is well organized.

Figure 20 Project window

 Write Bug Free Code


NetBeans provides static analysis tools, especially integration with the widely
used find bugs tool, for identifying and fixing common problems in Java code. In
addition, the NetBeans Debugger lets you place breakpoints in your source code,
add field watches, step through your code, run into methods, take snapshots and
monitor execution as it occurs.

Mohammed Basith Programming with Java 72


Figure 21 Break point

 Improve Performance
The NetBeans Profiler provides expert assistance for optimizing your application's
speed and memory usage, and makes it easier to build reliable and scalable Java
SE, JavaFX and Java EE applications. NetBeans IDE includes a visual debugger
for Java SE applications, letting you debug user interfaces without looking into
source code. 

Figure 22 NetBeans profiler

 Support for Multiple Languages


NetBeans IDE offers superior support for C/C++ and PHP developers, providing
comprehensive editors and tools for their related frameworks and technologies. In
addition, the IDE has editors and tools for XML, HTML, PHP, Groovy, Javadoc,
JavaScript, and JSP.

Mohammed Basith Programming with Java 73


4 Task 4: Be able to test and document Java solutions
4.1 Provide suitable test plan to critically review and test the developed system.
Project Name Read With Us library management system
Access management.
Add new books, update, remove, view and search.
Add new member, update, remove, view and search.
Book release. (selections, date count, release book, update)
Test plan
Book return. (selection, remove record)
objectives
Add payment, amount count, remove record.
Create, update, remove accounts. (Librarian, Member)
View and search fines.
Overdue details (selection, amount and date count)
Test type White box testing / Black box testing
Testing Process
Description
(Librarian)
1. Login 1.1. Log to system according to username and
password.
2. Book 2.1. Add new book to the system.
2.2. Update and remove entered book details.
2.3. View and search book details.

3. Member 3.1. Add new member to the system.


3.2. Update and remove entered member details.
3.3. View and search book details
4. Book 4.1. Select from tables.
Release 4.2. Load system date and day addition.
4.3. Book release and update.
5. Book 5.1. Select from table.
Return 5.2. Validation and remove record.
6. Payment 6.1. Add payment details to the system.
6.2. Amount count.
6.3. Validate and remove record.
7. New user 7.1. Create accounts for member.

Mohammed Basith Programming with Java 74


7.2. Search and select from table.
7.3. Remove accounts.
8. Fines 8.1. View fines.
8.2. Search fine details
Table 15 Test Plan for Librarian

Testing Process (Member) Description


9. Book 9.1. View and search book details.
10. Book Release 10.1. Select from tables.
10.2. Load system date and day addition.
10.3. Validation and book release.
11. Update user 11.1. Update own details
12. Overdue 12.1. Select from table.
12.2. Date count.
12.3. Amount count.
Table 16 Test Plan for member

Testing Process (Super user) Description


13. New user 13.1. Create librarian accounts and remove accounts.
Table 17 Test Plan for super user

Mohammed Basith Programming with Java 75


4.2 Provide suitable test cases to analyze the expected test results against actual
outputs to identify discrepancies.
1. Login

Test Case ID Test data


Case 1.1 //Check Login Credentials and Give permissions to access
public static String loginFunction(String user, String pass) {
String status = "NOT";
String access = "";
String member_name;
String user_name;
try {c = DBConnection.getMyConnection();
s = c.createStatement();
ResultSet rs = s.executeQuery("SELECT * FROM tbl_user WHERE
user_name='" + user + "' AND password='" + pass + "'");
int count = rs.last() ? rs.getRow() : 0;
//System.out.println(count);
if (count == 1) {
access = rs.getString("user_access");
JOptionPane.showMessageDialog(null, "Logged as :" + access,
"LOGIN ALERT", JOptionPane.INFORMATION_MESSAGE);
if ("Administrator".equals(access)) {
new SUPER_USER_MENU().setVisible(true);
member_name = rs.getString("user_name");
SUPER_USER_MENU.LBL_User.setText(member_name);
status = "OK";
} else if ("Member".equals(access)) {
new MEMBER_MAIN_MENU().setVisible(true);
status = "OK";
user_name = rs.getString("user_name");
MEMBER_MAIN_MENU.LBL_User.setText(user_name);
member_name = rs.getString("member_name");
MEMBER_MAIN_MENU.Txt_Book_Release_Member.setText(member_name);
MEMBER_MAIN_MENU.ID.setText(member_name);
} else if ("Librarian".equals(access)) {
new LIBRARIAN_MAIN_MENU().setVisible(true);
member_name = rs.getString("user_name");
LIBRARIAN_MAIN_MENU.LBL_User.setText(member_name);
status = "OK";

Mohammed Basith Programming with Java 76


}} else {
JOptionPane.showMessageDialog(null, "CHECK YOUR
CREDENTIALS...!", "LOGIN ALERT", JOptionPane.ERROR_MESSAGE);
}} catch (Exception e){e.printStackTrace();}return status;}

Purpose System needs to access multiple users. Without above function, user cannot
access to the system. Therefore, above code lines should be tested.
Results Show message including “CHECK YOUR CREDENTIALS...!” text.
Show message including “Logged as Administrator” text.
Show message including “Logged as Member” text.
Show message including “Logged as Librarian” text.
Table 18 Login test case

Librarian functions
2. Book

Test Case ID Test data


Case 2.1 CLASS_BOOKS.addBooks(Txt_Book_Book_Name.getText(),
Txt_Book_Author_Name.getText(),
Combo_Book_Category.getSelectedItem().toString(),
Txt_Book_Comment.getText());
//Add Books to the System
public static void addBooks(String bname, String aname, String category,
String comment) {
try {
c = DBConnection.getMyConnection();
s = c.createStatement();
s.executeUpdate("INSERT INTO tbl_books
(book_name,author_name,category,comment) VALUES('" + bname + "','" + aname +
"','" + category + "','" + comment + "')");
} catch (Exception ex) {
ex.printStackTrace();
}
}

Purpose We cannot add book details without this query and function. So this query
and function want to test carefully.
Results Show message including “RECORD ENTERED SUCCESSFULLY...!” text.
Table 19 Add book test case

Mohammed Basith Programming with Java 77


Test Case ID Test data
Case 2.2 CLASS_BOOKS.updateBooks(Integer.parseInt(ID.getText()),
Txt_Book_Book_Name.getText(), Txt_Book_Author_Name.getText(),
Combo_Book_Category.getSelectedItem().toString(),
Txt_Book_Comment.getText());

// Update Book Details


public static void updateBooks(int id, String bname, String aname,
String category, String comment) {
try {
c = DBConnection.getMyConnection();
s = c.createStatement();
s.executeUpdate("UPDATE tbl_books SET book_name='" + bname +
"',author_name='" + aname + "',category='" + category + "',comment='" +
comment + "' WHERE book_id='" + id + "'");
} catch (Exception ex) {
ex.printStackTrace();
}
}

CLASS_BOOKS.deleteBook(Integer.parseInt(ID.getText()));
//Delete selected Book Details
public static void deleteBook(int id) {
try {
c = DBConnection.getMyConnection();
s = c.createStatement();
s.executeUpdate("DELETE FROM tbl_books WHERE book_id='" + id +
"'");} catch (Exception ex) {
ex.printStackTrace();
}}

Purpose These update and delete functions are the important functions related books.
If user want to update or remove book details, these functions help to perform
that.
Results Show message including “RECORD UPDATED SUCCESSFULLY...!” text.
Show message including “RECORD REMOVED SUCCESSFULLY...!” text.
Table 20 Update & remove book test case

Mohammed Basith Programming with Java 78


Test Case ID Test data
Case 2.3 //Load Books To table
public static void loadBookTable() {
try {
c = DBConnection.getMyConnection();
s = c.createStatement();
dtm = (DefaultTableModel)
LIBRARIAN_MAIN_MENU.Table_Books.getModel();
rs = s.executeQuery("SELECT * FROM tbl_books");
while (rs.next()) {
Vector v = new Vector();
v.add(rs.getString("book_name"));
v.add(rs.getString("author_name"));
v.add(rs.getString("category"));
v.add(rs.getString("comment"));
dtm.addRow(v);
}
} catch (Exception e) {
e.printStackTrace();
}
}
//Search table according to book name
public static void searchBookName(String bname) {
try {
c = DBConnection.getMyConnection();
s = c.createStatement();
dtm = (DefaultTableModel)
LIBRARIAN_MAIN_MENU.Table_Books.getModel();
rs = s.executeQuery("select * from tbl_books where book_name
like '" + bname + "%'");
dtm.setRowCount(0);
while (rs.next()) {
Vector v = new Vector();
v.add(rs.getString("book_name"));
v.add(rs.getString("author_name"));
v.add(rs.getString("category"));
v.add(rs.getString("comment"));
dtm.addRow(v);
}

Mohammed Basith Programming with Java 79


} catch (Exception e) {
e.printStackTrace();
}
}
//Search table according to Author name
public static void searchBookAuthor(String aname) {
try {
c = DBConnection.getMyConnection();
s = c.createStatement();
dtm = (DefaultTableModel)
LIBRARIAN_MAIN_MENU.Table_Books.getModel();
rs = s.executeQuery("select * from tbl_books where author_name
like '" + aname + "%'");
dtm.setRowCount(0);
while (rs.next()) {
Vector v = new Vector();
v.add(rs.getString("book_name"));
v.add(rs.getString("author_name"));
v.add(rs.getString("category"));
v.add(rs.getString("comment"));
dtm.addRow(v);
}
} catch (Exception e) {
e.printStackTrace();
}
}

Purpose These functions allows to load book details to the table and search loaded
details according to book name and author name. Therefore, these function
should be tested.
Results

Table 21 View & search book test case

Mohammed Basith Programming with Java 80


3. Member

Test Case ID Test data


Case 3.1 CLASS_MEMBER.addMember(Txt_Member_Member_Name.getText(),
Txt_Member_Member_Address.getText(), Txt_Member_Member_NIC.getText(),
Txt_Member_Contact_No.getText(), Txt_Member_Email.getText());
//Add Members to the System
public static void addMember(String mname,String maddress,String
mnic,String mcontact,String mail){
try {
c = DBConnection.getMyConnection();
s = c.createStatement();
s.executeUpdate("INSERT INTO tbl_member
(member_name,member_address,member_nic,member_contact,email) VALUES('" +
mname + "','" + maddress + "','" + mnic + "','" + mcontact + "','"+ mail
+"')");
} catch (Exception ex) {
ex.printStackTrace();
}
}

Purpose We cannot add member details without this query and function. So this query
and function want to test carefully.
Results Show message including “RECORD ENTERED SUCCESSFULLY...!” text.
Table 22 Add member test case

Mohammed Basith Programming with Java 81


Test Case ID Test data
Case 3.2 CLASS_MEMBER.updateMember(Integer.parseInt(ID.getText()),
Txt_Member_Member_Name.getText(), Txt_Member_Member_Address.getText(),
Txt_Member_Member_NIC.getText(), Txt_Member_Contact_No.getText(),
Txt_Member_Email.getText());
//Update Member Details
public static void updateMember(int id,String mname,String
maddress,String mnic,String mcontact,String mail){
try {
c = DBConnection.getMyConnection();
s = c.createStatement();
s.executeUpdate("UPDATE tbl_member SET member_name='" + mname +
"',member_address='" + maddress + "',member_nic='" + mnic +
"',member_contact='" + mcontact + "',email='"+ mail +"' WHERE member_id='"+
id +"'");
} catch (Exception ex) {
ex.printStackTrace();
}
}
CLASS_MEMBER.deleteMember(Integer.parseInt(ID.getText()));
//Delete selected Member Details
public static void deleteMember(int id){

c = DBConnection.getMyConnection();
s = c.createStatement();
s.executeUpdate("DELETE FROM tbl_member WHERE member_id='"+ id +"'");

Purpose These update and delete functions are the important functions related
member. If user want to update or remove member details, these functions
help to perform that.
Results Show message including “RECORD UPDATED SUCCESSFULLY...!” text.
Show message including “RECORD REMOVED SUCCESSFULLY...!” text.
Table 23 Update & remove member test case

Mohammed Basith Programming with Java 82


Test Case ID Test data
Case 3.3 //Load Member Details
public static void loadMemberTable() {
try {
c = DBConnection.getMyConnection();
s = c.createStatement();
dtm = (DefaultTableModel)
LIBRARIAN_MAIN_MENU.Table_Member.getModel();
rs = s.executeQuery("SELECT * FROM tbl_member");
while (rs.next()) {
Vector v = new Vector();
v.add(rs.getString("member_name"));
v.add(rs.getString("member_address"));
v.add(rs.getString("member_nic"));
v.add(rs.getString("member_contact"));
v.add(rs.getString("email"));
dtm.addRow(v);
}
} catch (Exception e) {
e.printStackTrace();
}
}
//Search table according to Member name
public static void searchMemberName(String mname) {
try {
c = DBConnection.getMyConnection();
s = c.createStatement();
dtm = (DefaultTableModel)
LIBRARIAN_MAIN_MENU.Table_Member.getModel();
rs = s.executeQuery("select * from tbl_member where member_name
like '" + mname + "%'");
dtm.setRowCount(0);
while (rs.next()) {
Vector v = new Vector();
v.add(rs.getString("member_name"));
v.add(rs.getString("member_address"));
v.add(rs.getString("member_nic"));
v.add(rs.getString("member_contact"));
v.add(rs.getString("email"));

Mohammed Basith Programming with Java 83


dtm.addRow(v);
}
} catch (Exception e) {
e.printStackTrace();
}
}
//Search table according to Member NIC
public static void searchMemberNIC(String nic) {
try {
c = DBConnection.getMyConnection();
s = c.createStatement();
dtm = (DefaultTableModel)
LIBRARIAN_MAIN_MENU.Table_Member.getModel();
rs = s.executeQuery("select * from tbl_member where member_nic
like '" + nic + "%'");
dtm.setRowCount(0);
while (rs.next()) {
Vector v = new Vector();
v.add(rs.getString("member_name"));
v.add(rs.getString("member_address"));
v.add(rs.getString("member_nic"));
v.add(rs.getString("member_contact"));
v.add(rs.getString("email"));
dtm.addRow(v);
}
} catch (Exception e) {
e.printStackTrace();
}
}

Purpose These functions allows to load member details to the table and search loaded
details according to member name and NIC. Therefore, these function should
be tested.
Results

Table 24 View & search member test case

Mohammed Basith Programming with Java 84


4. Book Release

Test Case ID Test data


Case 4.1 int selectedRow = Table_Release_Book1.getSelectedRow();
DefaultTableModel dtm = (DefaultTableModel)
Table_Release_Book1.getModel();
Txt_Release_Add_Book1.setText(dtm.getValueAt(selectedRow,
0).toString());

int selectedRow = Table_Release_Book2.getSelectedRow();


DefaultTableModel dtm = (DefaultTableModel)
Table_Release_Book2.getModel();
Txt_Release_Add_Book2.setText(dtm.getValueAt(selectedRow,
0).toString());

int selectedRow = Table_Release_Member.getSelectedRow();


DefaultTableModel dtm = (DefaultTableModel)
Table_Release_Member.getModel();
Txt_Release_Add_Member.setText(dtm.getValueAt(selectedRow,
0).toString());

Purpose These codes are helping to fill the textfiels according to selected row. Without
these codes, librarian cannot perform book releasing process quickly.
Results

Table 25 data selection test case

Mohammed Basith Programming with Java 85


Test Case ID Test data
Case 4.2 //Count Current Date
public void currentDate() {
Calendar cal = new GregorianCalendar();
int month = cal.get(Calendar.MONTH);
int year = cal.get(Calendar.YEAR);
int day = cal.get(Calendar.DAY_OF_MONTH);
LBL_Date.setText((month + 1) + "/" + day + "/" + year);
Txt_Release_Add_Release_Date.setText((month + 1) + "/" + day + "/" +
year);
Txt_Book_Return_Return_Date.setText((month + 1) + "/" + day + "/" +
year);
}

//Add 14 days to current date and Set It to Jtextfields


public void dateDeference() {
Date currentDate = new Date();
// convert date to calendar
Calendar c = Calendar.getInstance();
c.setTime(currentDate);
c.add(Calendar.DATE, 14);
// convert calendar to date
Date currentDatePlusOne = c.getTime();
Txt_Release_Add_Reture_Date.setText(dateFormat.format(currentDatePlu
sOne));
}

Purpose These functions are responsible for dates. First function get the date from
system and other one adds 14 days to current date. These functions helps to
book release and return processes.
Results

Table 26 Date relate functions test case

Mohammed Basith Programming with Java 86


Test Case ID Test data
Case 4.3 CLASS_BOOK_RELEASE.releaseBooks(Txt_Release_Add_Book1.getText(),
Txt_Release_Add_Book2.getText(), Txt_Release_Add_Member.getText(),
Txt_Release_Add_Release_Date.getText(),
Txt_Release_Add_Reture_Date.getText());
//Release Books to the Members
public static void releaseBooks(String book1, String book2, String
member, String start_date,String end_date) {
try {
c = DBConnection.getMyConnection();
s = c.createStatement();
s.executeUpdate("INSERT INTO tbl_book_release
(book1,book2,member_name,release_date,return_date) VALUES('" + book1 + "','"
+ book2 + "','" + member + "','" + start_date + "','"+ end_date +"')");
} catch (Exception ex) {
ex.printStackTrace();
}
}
CLASS_BOOK_RELEASE.updateSchedule(Integer.parseInt(ID.getText()),
Txt_Release_Add_Book1.getText(), Txt_Release_Add_Book2.getText(),
Txt_Release_Add_Member.getText());
// Update Schedule Details
public static void updateSchedule(int id,String book1,String
book2,String member){
try {
c = DBConnection.getMyConnection();
s = c.createStatement();
s.executeUpdate("UPDATE tbl_book_release SET book1='" + book1 +
"',book2='" + book2 + "',member_name='" + member + "' WHERE release_id='"+
id +"'");
} catch (Exception ex) {
ex.printStackTrace();
}
}

Purpose One of these functions help librarian to release books to the members. And
also, other one helps to update in any case. So these functions should be
tested.
Results Show message including “BOOK RELEASED...!” text.

Mohammed Basith Programming with Java 87


Show message including “RECORD UPDATED SUCCESSFULLY...!” text.
Table 27 Book release & update test case

5. Book Return

Test Case ID Test data


Case 5.1 if (evt.getClickCount() == 2 && !evt.isConsumed()) {
evt.consume();
int selectedRow = Table_Book_Return.getSelectedRow();
DefaultTableModel dtm = (DefaultTableModel)
Table_Book_Return.getModel();
Txt_Book_Return_Member_Name.setText(dtm.getValueAt(selectedRow,
0).toString());
Txt_Book_Return_Book1.setText(dtm.getValueAt(selectedRow,
1).toString());
Txt_Book_Return_Book2.setText(dtm.getValueAt(selectedRow,
2).toString());
Txt_Book_Return_Release_Date.setText(dtm.getValueAt(selectedRow,
3).toString());
CLASS_BOOK_RETURN.loadScheduleID(Txt_Book_Return_Member_Name.get
Text());
dateCount();
}
//Get date diference
public void dateCount() {
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
try {
Date date1 = sdf.parse(Txt_Book_Return_Release_Date.getText());
Date date2 = sdf.parse(Txt_Book_Return_Return_Date.getText());
long diff = date2.getTime() - date1.getTime();
Txt_Book_Return_Days.setText(String.valueOf(TimeUnit.DAYS.conver
t(diff, TimeUnit.MILLISECONDS)));
} catch (Exception e) {
e.printStackTrace();
}
}

Purpose These codes are helping to fill the textfiels according to selected row. Without
these codes, librarian cannot perform book returning process quickly. And
also,dateCount() get the date diference between two dates.
Table 28 Book return data selection test case

Mohammed Basith Programming with Java 88


Test Case ID Test data
Case 5.2 if (!"".equals(Txt_Book_Return_Member_Name.getText())
&& !"".equals(Txt_Book_Return_Release_Date.getText())
&& !"".equals(Txt_Book_Return_Days.getText())) {
if (Integer.parseInt(Txt_Book_Return_Days.getText()) <= val) {
CLASS_BOOK_RETURN.deleteScedule(Integer.parseInt(ID.getText(
)));
JOptionPane.showMessageDialog(null, "BOOK RETURNED", "BOOK
RETURN ALERT", JOptionPane.INFORMATION_MESSAGE);
Txt_Book_Return_Member_Name.setText(null);
Txt_Book_Return_Book1.setText(null);
Txt_Book_Return_Book2.setText(null);
Txt_Book_Return_Release_Date.setText(null);
Txt_Book_Return_Days.setText(null);
DefaultTableModel dtm = (DefaultTableModel)
Table_Book_Return.getModel();
dtm.setRowCount(0);
CLASS_BOOK_RETURN.loadReturnBookTable();
DefaultTableModel dtm1 = (DefaultTableModel)
Table_Release_Book_Schedule.getModel();
dtm1.setRowCount(0);
CLASS_BOOK_RELEASE.loadReleaseBookTable();
} else {
JOptionPane.showMessageDialog(null, "YOUR GRACE PERIOD IS
EXCEEDED.\nCLICK ON PAY BUTTON", "ERROR ALERT", JOptionPane.ERROR_MESSAGE);
}
} else {
JOptionPane.showMessageDialog(null, "PLEASE SELECT A ROW",
"ERROR ALERT", JOptionPane.ERROR_MESSAGE);
}
//Delete selected Schedule Details
public static void deleteScedule(int id){
try {
c = DBConnection.getMyConnection();
s = c.createStatement();
s.executeUpdate("DELETE FROM tbl_book_release WHERE
release_id='"+ id +"'");
} catch (Exception ex) {
ex.printStackTrace();

Mohammed Basith Programming with Java 89


}
}

Purpose One of these functions help librarian to release books to the members. And
also, other one helps to update in any case. So these functions should be
tested.
Results Show message including “YOUR GRACE PERIOD IS EXCEEDED.\nCLICK ON
PAY BUTTON” text.
Show message including “PLEASE SELECT A ROW” text.
Show message including “BOOK RETURNED” text.
Table 29 Validation & remove released books test case

6. Payment

Test Case ID Test data


Case 6.1 CLASS_PAYMENT.addPayment(Txt_Payment_Member_Name.getText(),
Txt_Payment_Release_Date.getText(),Txt_Payment_Return_Date.getText(),
Integer.parseInt(Txt_Payment_days.getText()),
Integer.parseInt(Txt_Payment_Fine_Amount.getText()));
//Add payment details to the system
public static void addPayment(String name, String release_date, String
return_date, int days, int amount){
try {
c = DBConnection.getMyConnection();
s = c.createStatement();
s.executeUpdate("INSERT INTO tbl_payment
(member_name,release_date,return_date,days,amount) VALUES('" + name + "','"
+ release_date + "','" + return_date + "','" + days + "','" + amount +
"')");
} catch (Exception ex) {
ex.printStackTrace();}}

Purpose This function stores the payment details in the database. Librarian wants to
check payment details later. Without this function, librarian cannot do that.
Results Show message including “PAYMENT SUCCESSFULL...!” text.
Show message including “PAYMENT UNSUCCESSFULLY” text.
Table 30 Add payment test case

Mohammed Basith Programming with Java 90


Test Case ID Test data
Case 6.2 CLASS_PAYMENT.fineAmount();
// Calculate fines
public static void fineAmount(){
int day_fine = 5;
int days = Integer.parseInt(PAYMENT.Txt_Payment_days.getText()) -
14;
int fine;
if("".equals(LIBRARIAN_MAIN_MENU.Txt_Book_Return_Book1.getText()) &&
"".equals(LIBRARIAN_MAIN_MENU.Txt_Book_Return_Book2.getText())){
JOptionPane.showMessageDialog(null, "YOU HAVE TO SELECT ATLEAST
1 BOOK", "ERROR ALERT", JOptionPane.ERROR_MESSAGE);
}else
if(!"".equals(LIBRARIAN_MAIN_MENU.Txt_Book_Return_Book1.getText())
&& !"".equals(LIBRARIAN_MAIN_MENU.Txt_Book_Return_Book2.getText())){
fine = (day_fine * days) * 2 ;
PAYMENT.Txt_Payment_Fine_Amount.setText(String.valueOf(fine));
}else
if("".equals(LIBRARIAN_MAIN_MENU.Txt_Book_Return_Book2.getText())){
fine = day_fine * days;
PAYMENT.Txt_Payment_Fine_Amount.setText(String.valueOf(fine));
}else
if("".equals(LIBRARIAN_MAIN_MENU.Txt_Book_Return_Book1.getText())){
fine = day_fine * days;
PAYMENT.Txt_Payment_Fine_Amount.setText(String.valueOf(fine));}}

Purpose This function calculate the fine amount according the book count and day
count. This function directly responsible for generate payments. So, this
should be tested.
Results

Table 31 Amount count function test case

Mohammed Basith Programming with Java 91


Test Case ID Test data
Case 6.3 if (!"".equals(Txt_Book_Return_Member_Name.getText())
&& !"".equals(Txt_Book_Return_Book1.getText())
&& !"".equals(Txt_Book_Return_Book2.getText())
&& !"".equals(Txt_Book_Return_Release_Date.getText())
&& !"".equals(Txt_Book_Return_Days.getText())) {
if (Integer.parseInt(Txt_Book_Return_Days.getText()) > val) {
if (p != null) {
p.setVisible(true);
PAYMENT.Txt_Payment_Member_Name.setText(
Txt_Book_Return_Member_Name.getText());
PAYMENT.Txt_Payment_Release_Date.setText(
Txt_Book_Return_Release_Date.getText());
PAYMENT.Txt_Payment_Return_Date.setText(
Txt_Book_Return_Return_Date.getText());
PAYMENT.Txt_Payment_days.setText(Txt_Book_Return_Days.getText());
CLASS_PAYMENT.fineAmount();} else {
p = new PAYMENT();
p.setVisible(true);
PAYMENT.Txt_Payment_Member_Name.setText(Txt_Book_
Return_Member_Name.getText());
PAYMENT.Txt_Payment_Release_Date.setText(Txt_Book
_Return_Release_Date.getText());
PAYMENT.Txt_Payment_Return_Date.setText(Txt_Book_
Return_Return_Date.getText());
PAYMENT.Txt_Payment_days.setText(Txt_Book_Return_Days.getText());
CLASS_PAYMENT.fineAmount();
}} else {
JOptionPane.showMessageDialog(null, "YOUR GRACE PERIOD ISN`T EXCEED.
\nCLICK ON RETURN BOOKS BUTTON", "ERROR ALERT", JOptionPane.ERROR_MESSAGE);
} } else {
JOptionPane.showMessageDialog(null, "PLEASE SELECT A ROW", "ERROR ALERT",
JOptionPane.ERROR_MESSAGE);}

Purpose One of these functions help librarian to release books to the members. And
also, other one helps to update in any case. So these functions should be
tested.
Results Show message including “YOUR GRACE PERIOD ISN`T EXCEED.\nCLICK ON
RETURN BOOKS BUTTON” text.
Show message including “PLEASE SELECT A ROW” text.
Show message including “PAYMENT SUCCESSFUL” text.
Table 32 Validation & remove released books test case

Mohammed Basith Programming with Java 92


7. New User

Test Case ID Test data


Case 7.1 CLASS_USER.addUsers(Txt_User_MemberName.getText(),
Txt_User_Username.getText(),
Arrays.toString(Txt_User_Confirm.getPassword()), Txt_User_Access.getText());
//Add users to the System
public static void addUsers(String mname, String user, String pass,
String access) {
try {
c = DBConnection.getMyConnection();
s = c.createStatement();
s.executeUpdate("INSERT INTO tbl_user
(member_name,user_name,password,user_access) VALUES('" + mname + "','" +
user + "','" + pass + "','" + access + "')");
} catch (Exception ex) {
ex.printStackTrace();}}

Purpose This function creates the accounts for the members. Without this function,
librarian cannot do that.
Results Show message including “RECORD ADDED SUCCESSFULLY...!” text.
Show message including “PASSWORD DID NOT MATCH...!” text.
Table 33 Create account test case

Test Case ID Test data


Case 7.2 int selectedRow = Table_User_Member.getSelectedRow();
DefaultTableModel dtm = (DefaultTableModel)
Table_User_Member.getModel();
Txt_User_MemberName.setText(dtm.getValueAt(selectedRow,
0).toString());
CLASS_USER.searchMemberName(Txt_User_Search_Member.getText());
//Search table according to Member name
public static void searchMemberName(String mname) {
try {c = DBConnection.getMyConnection();
s = c.createStatement();
dtm = (DefaultTableModel)
LIBRARIAN_MAIN_MENU.Table_User_Member.getModel();
rs = s.executeQuery("select * from tbl_member where member_name
like '" + mname + "%'");
dtm.setRowCount(0);
while (rs.next()) {

Mohammed Basith Programming with Java 93


Vector v = new Vector();
v.add(rs.getString("member_name"));
v.add(rs.getString("member_nic"));
dtm.addRow(v);
}} catch (Exception e){e.printStackTrace();}}

Purpose This sattement helps to load selected row details into textfields. Above
mentioned method helps to search member details according to member
name.
Results

Table 34 Search & select record test case

Test Case ID Test data


Case 7.3 CLASS_USER.deleteUser(Integer.parseInt(ID.getText()));
//Delete selected user Details
public static void deleteUser(int id) {
try {
c = DBConnection.getMyConnection();
s = c.createStatement();
s.executeUpdate("DELETE FROM tbl_user WHERE user_id='" + id +
"'");
} catch (Exception ex) {
ex.printStackTrace();
}
}

Purpose This function removes the accounts of members. Without this function,
librarian cannot do that. Therefore, this should be tested.
Results Show message including “RECORD DELETED SUCCESSFULLY...!” text.
Table 35 Remove accounts test case

8. Fines

Mohammed Basith Programming with Java 94


Test Case ID Test data
Case 8.1 //Load Fine Details
public static void loadFinesTable() {
try {
c = DBConnection.getMyConnection();
s = c.createStatement();
dtm = (DefaultTableModel)
LIBRARIAN_MAIN_MENU.Table_Fines.getModel();
rs = s.executeQuery("SELECT * FROM tbl_payment");
while (rs.next()) {
Vector v = new Vector();
v.add(rs.getString("member_name"));
v.add(rs.getString("release_date"));
v.add(rs.getString("return_date"));
v.add(rs.getString("days"));
v.add(rs.getString("amount"));
dtm.addRow(v);
}
} catch (Exception e) {
e.printStackTrace();}}

Purpose This function load fine details to the fine table. Without this function,
librarian cannot manage payment details. Therefore, this function should be
tested.
Results

Table 36 View fine test case

Test Case ID Test data

Mohammed Basith Programming with Java 95


Case 8.2 //Search table according to Member name
public static void searchMemberName(String mname) {
try {
c = DBConnection.getMyConnection();
s = c.createStatement();
dtm = (DefaultTableModel)
LIBRARIAN_MAIN_MENU.Table_Fines.getModel();
rs = s.executeQuery("select * from tbl_payment where member_name
like '" + mname + "%'");
dtm.setRowCount(0);
while (rs.next()) {
Vector v = new Vector();
v.add(rs.getString("member_name"));
v.add(rs.getString("release_date"));
v.add(rs.getString("return_date"));
v.add(rs.getString("days"));
v.add(rs.getString("amount"));
dtm.addRow(v);
}

} catch (Exception e) {
e.printStackTrace();
}
}

Purpose This function helps to search loaded fine details according to member nane.
Librarian can search and get details in member wise. Therefore, this function
should be tested.
Results

Table 37 Search fines test case

Member Functions

Mohammed Basith Programming with Java 96


9. Book

Test Case ID Test data


Case 9.1 //Load Books To table Member UI
public static void loadMemberBooks() {
try {c = DBConnection.getMyConnection();
s = c.createStatement();
dtm = (DefaultTableModel)
MEMBER_MAIN_MENU.Table_Member_Books.getModel();
rs = s.executeQuery("SELECT * FROM tbl_books");
while (rs.next()) {
Vector v = new Vector();
v.add(rs.getString("book_name"));
v.add(rs.getString("author_name"));
v.add(rs.getString("category"));
v.add(rs.getString("comment"));
dtm.addRow(v);}} catch (Exception e) {
e.printStackTrace();}}
//Search table Member UI according to book name
public static void searchMemberBookName(String bname) {
try {c = DBConnection.getMyConnection();
s = c.createStatement();
dtm = (DefaultTableModel)
MEMBER_MAIN_MENU.Table_Member_Books.getModel();
rs = s.executeQuery("select * from tbl_books where book_name
like '" + bname + "%'");
dtm.setRowCount(0);
while (rs.next()) {
Vector v = new Vector();
v.add(rs.getString("book_name"));
v.add(rs.getString("author_name"));
v.add(rs.getString("category"));
v.add(rs.getString("comment"));
dtm.addRow(v);}} catch (Exception e) {
e.printStackTrace();}}
//Search table Member UI according to Author name
public static void searchMemberBookAuthor(String aname) {
try {c = DBConnection.getMyConnection();
s = c.createStatement();
dtm = (DefaultTableModel)
MEMBER_MAIN_MENU.Table_Member_Books.getModel();
rs = s.executeQuery("select * from tbl_books where author_name
like '" + aname + "%'");

Mohammed Basith Programming with Java 97


dtm.setRowCount(0);
while (rs.next()) {
Vector v = new Vector();
v.add(rs.getString("book_name"));
v.add(rs.getString("author_name"));
v.add(rs.getString("category"));
v.add(rs.getString("comment"));
dtm.addRow(v);}} catch (Exception e) {
e.printStackTrace();}
}

Purpose loadMemberBook() function helps to load member details to the member


table. searchMemberBookName() and searchMemberBookAuthor() functions
help to search book details according to book name or author. These functions
allow users to find books before reserve. Therefore, these functions should be
tested.
Results

Table 38 View & search books(member) test case

10. Book Release

Test Case ID Test data

Mohammed Basith Programming with Java 98


Case 10.1 if (evt.getClickCount() == 2 && !evt.isConsumed()) {
evt.consume();
int selectedRow = Table_Book_Release1.getSelectedRow();
DefaultTableModel dtm = (DefaultTableModel)
Table_Book_Release1.getModel();
Txt_Book_Release_Book1.setText(dtm.getValueAt(selectedRow,
0).toString());
}
if (evt.getClickCount() == 2 && !evt.isConsumed()) {
evt.consume();
int selectedRow = Table_Book_Release2.getSelectedRow();
DefaultTableModel dtm = (DefaultTableModel)
Table_Book_Release2.getModel();
Txt_Book_Release_Book2.setText(dtm.getValueAt(selectedRow,
0).toString());
}

Purpose These code snippets are helping member to select books for reserving. They
have to enter manually, if these selection codes doesn`t exist. Therefore, this
should be tested.
Results

Table 39 Book release data selection (member) test case

Test Case ID Test data

Mohammed Basith Programming with Java 99


Case 10.2 //Count Current Date
public void currentDate() {
Calendar cal = new GregorianCalendar();
int month = cal.get(Calendar.MONTH);
int year = cal.get(Calendar.YEAR);
int day = cal.get(Calendar.DAY_OF_MONTH);
LBL_Date.setText((month + 1) + "/" + day + "/" + year);
Txt_Release_Add_Release_Date.setText((month + 1) + "/" + day + "/" +
year);
Txt_Book_Return_Return_Date.setText((month + 1) + "/" + day + "/" +
year);
}
//Add 14 days to current date and Set It to Jtextfields
public void dateDeference() {
Date currentDate = new Date();
// convert date to calendar
Calendar c = Calendar.getInstance();
c.setTime(currentDate);
c.add(Calendar.DATE, 14);
// convert calendar to date
Date currentDatePlusOne = c.getTime();
Txt_Release_Add_Reture_Date.setText(dateFormat.format(currentDatePlusOne));
}

Purpose These functions are responsible for dates. First function get the date from
system and other one adds 14 days to current date. These functions helps to
book release and return processes.
Results

Table 40 Date related functions (member) test case

Test Case ID Test data

Mohammed Basith Programming with Java 100


Case 10.3 if (rows == 1) {
JOptionPane.showMessageDialog(null,
"YOU HAVE TO RETURN BORROWED BOOKS.\nBEFORE GET ANOTHER",
"WARNING ALERT", JOptionPane.WARNING_MESSAGE);
} else {
CLASS_BOOK_RELEASE.releaseBooks(
Txt_Book_Release_Book1.getText(), Txt_Book_Release_Book2.getText(),
Txt_Book_Release_Member.getText(),
Txt_Book_Release_Release_date.getText(),
Txt_Book_Release_Return_Date.getText());
JOptionPane.showMessageDialog(null, "RECORD ENTERED
SUCCESSFULLY...!", "INSERT ALERT", JOptionPane.INFORMATION_MESSAGE);
DefaultTableModel dtm = (DefaultTableModel)
Table_Release_Details.getModel();
dtm.setRowCount(0);
CLASS_BOOK_RELEASE.loadReleaseMemberBookTable(
Txt_Book_Release_Member.getText());}

Purpose This validation prevents the chance to get extra books before books return
process. According to this function, if member reserved books, he or she must
return that books before get the new one. This is the security validation and
this should be tested.
Results Show message including “YOU HAVE TO RETURN BORROWED BOOKS. \
nBEFORE GET ANOTHER” text.

Show message including “BOOK RESERVED…! text.


Table 41 Validation & book release (member) test case

11. Update User

Mohammed Basith Programming with Java 101


Test Case ID Test data
Case 11.1 CLASS_USER.updateMemberUser(Integer.parseInt(ID2.getText()),
Txt_User_MemberName.getText(), Txt_User_Username.getText(), new
String(Txt_User_Confirm.getPassword()));
// Update User Details
public static void updateMemberUser(int id, String mname, String user,
String pass) {
try {
c = DBConnection.getMyConnection();
s = c.createStatement();
s.executeUpdate("UPDATE tbl_user SET member_name='" + mname +
"',user_name='" + user + "',password='" + pass + "' WHERE user_id='" + id +
"'");
} catch (Exception ex) {
ex.printStackTrace();}}

Purpose This function allows members to update own credentials after creating the
user accounts. This function prevents the interference of the member accounts
even librarian.
Results Show message including “RECORD UPDATED SUCCESSFULLY...!” text.
Show message including “PASSWORD DID NOT MATCH...!” text.
Table 42 Update member details (member) test case

12. Overdue

Mohammed Basith Programming with Java 102


Test Case ID Test data
Case 12.1 if (evt.getClickCount() == 2 && !evt.isConsumed()) {
evt.consume();
int selectedRow = Table_Over_Due.getSelectedRow();
DefaultTableModel dtm = (DefaultTableModel) Table_Over_Due.getModel();
Txt_Over_Member_Name.setText(dtm.getValueAt(selectedRow, 2).toString());
Txt_Over_Book1.setText(dtm.getValueAt(selectedRow, 0).toString());
Txt_Over_Book2.setText(dtm.getValueAt(selectedRow, 1).toString());
Txt_Over_Release_Date.setText(dtm.getValueAt(selectedRow, 3).toString());}

Purpose Member wants to see the overdue details of the borrowed books. If member
select the row, all details will be show in a particular text fields. If this
selection codes doesn`t work properly, member have to count days and
amount manually.
Results

Table 43 Data selection in overdue (member) test case

Test Case ID Test data

Mohammed Basith Programming with Java 103


Case 12.2 //Get date diference
public void dateCount() {
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
try {
Date date1 = sdf.parse(Txt_Over_Release_Date.getText());
Date date2 = sdf.parse(Txt_Over_Return_Date.getText());
long diff = date2.getTime() - date1.getTime();
Txt_Over_Days.setText(String.valueOf(TimeUnit.DAYS.convert(diff,
TimeUnit.MILLISECONDS)));
// System.out.println ("Days: " + TimeUnit.DAYS.convert(diff,
TimeUnit.MILLISECONDS));
} catch (Exception e) {
e.printStackTrace();}}

Purpose This function gets the current date and book released date. After that counts,
the date count. Without this function, we cannot count the day count.
Therefore, this function is very important.
Results

Table 44 date count function (member) test case

Test Case ID Test data

Mohammed Basith Programming with Java 104


Case 12.3 //Count Fines
public void fineCount() {
int amount = 0;
if (Integer.parseInt(Txt_Over_Days.getText()) <= 14) {
Txt_Over_Fine_Amount.setText(String.valueOf(amount));
} else {int days = Integer.parseInt(Txt_Over_Days.getText()) - 14;
int day_fine = 5;
int fine;
if ("".equals(Txt_Over_Book1.getText()) &&
"".equals(Txt_Over_Book2.getText())) {
JOptionPane.showMessageDialog(null, "YOU HAVE TO SELECT
ATLEAST 1 BOOK", "ERROR ALERT", JOptionPane.ERROR_MESSAGE);
} else if (!"".equals(Txt_Over_Book1.getText())
&& !"".equals(Txt_Over_Book2.getText())) {
fine = (day_fine * days) * 2;
Txt_Over_Fine_Amount.setText(String.valueOf(fine));
} else if ("".equals(Txt_Over_Book2.getText())) {
fine = day_fine * days;
Txt_Over_Fine_Amount.setText(String.valueOf(fine));
} else if ("".equals(Txt_Over_Book1.getText())) {
fine = day_fine * days;
Txt_Over_Fine_Amount.setText(String.valueOf(fine));}}

Purpose This function counts the fine amount according to day count. Without this
function, we cannot count the fine amount. Therefore, this function is very
important.
Results

Table 45 Amount count function (member) test case

Mohammed Basith Programming with Java 105


Super User Functions

13. New User

Test Case ID Test data


Case 13.1 CLASS_USER.addUsers(Txt_User_MemberName.getText(),
Txt_User_Username.getText(),
Arrays.toString(Txt_User_Confirm.getPassword()), Txt_User_Access.getText());
//Add users to the System
public static void addUsers(String mname, String user, String pass,
String access) {
try {
c = DBConnection.getMyConnection();
s = c.createStatement();
s.executeUpdate("INSERT INTO tbl_user
(member_name,user_name,password,user_access) VALUES('" + mname + "','" +
user + "','" + pass + "','" + access + "')");
} catch (Exception ex) {
ex.printStackTrace();
}
}
CLASS_USER.deleteUser(Integer.parseInt(ID.getText()));
//Delete selected user Details
public static void deleteUser(int id) {
try {
c = DBConnection.getMyConnection();
s = c.createStatement();
s.executeUpdate("DELETE FROM tbl_user WHERE user_id='" + id +
"'");
} catch (Exception ex) {
ex.printStackTrace();
}
}

Purpose This addUsers() function creates the accounts for the members. Without this
function, librarian cannot do that.
This deleteusers() function removes the accounts of members. Without this
function, librarian cannot do that. Therefore, this should be tested.
Results Show message including “RECORD ADDED SUCCESSFULLY...!” text.
Show message including “PASSWORD DID NOT MATCH...!” text.
Show message including “RECORD DELETED SUCCESSFULLY...!” text.
Table 46 Create & remove user accounts (super user) test case

Mohammed Basith Programming with Java 106


4.3 Evaluate independent feedback on your system

Without testing the newly created software solution, we cannot assure that
software. It can be included many bugs or irrelevant thing to client and as a
programmer, we should handle all of them. That’s how a qualified and error
free software solution created. In testing phase, programmer wants to get details
from clients because clients should have to give accurate details to the
programmers. But sometimes, this process can be little bit hard due to many
reasons like time management issues, busyness of the clients or responsible
persons and others. But this phase is the most important and very essential one.
Hence, I created the questionnaire for gather information about this software.
Because of using this method, I can gather information effectively.

When we using questionnaire, tester can identify that what should be tested and
software`s functionality. Therefore, tester can evaluate the software easily. After
the testing process, tester can fill the questionnaire and handover it to the
programmer. Then programmer check again the software and he can fix the
identified bugs. This is the usual process of testing. If we use questionnaire, we
can compare the properties of software with those of hardware and difference in
their development, management and control processes understand different
activities and focuses of software development process and its work product at
different steps.

Library management system is the newly created software solution. So,


library`s staff members cannot use this system quickly. Because, they didn`t use
this system before. So, I have to practice them to handle this system correctly. It
is the one of my responsibility. Therefore, I started parallel run program with
library people. Because of that library people can get a quick idea about
function of the system and also, they can learn how to operate them. So, I
provide above feedback form to them when they perform parallel run program. I
attached the feedback forms in appendixes. Following shows the
recommendations and future improvements of the system according to feedback
forms.

Mohammed Basith Programming with Java 107


Future Improvements
‘Read with Us’ library management system provide access privileges within members
and librarian also. And also, using this system, librarian can create the user accounts
or members to access to the system. After that, members can log in to the system
using that created user credentials and member also have a privilege to modify own
access credentials. Librarian can see the all of credentials and member also can see
the own details when member logged in to the system. But I prevented to show the
password for both of members. They can see the user name or access level and others.
But they cannot see the password from the system. I prevented it for security reasons.
But according to the feedback forms, that I included in appendix, they want to show
password from the system. Librarian wants to see the user name and password of all
the members and member wants to see the own password before or after change it.

Currently, user cannot get backups through this system because I didn`t provide that
facility. But, they need this function because, these details are the most important
thing in the whole system and it should be accurate. Sometimes, system data can be
corrupted due to wrong operation or external factor. At that time, they can save their
stored details if they can get a backup from system.

In current system, there is no any notification system. According to feedback forms,


suggested the 02 methods for notification system. First one is via email. Email is the
speed method for notification and I can distribute book released date, return date,
book names and payments if the member have through the email. This is the good
technology for notifications. Because, emails are safe and quick. With this function,
member can solve some sort of problems. Sometimes, member can be forgotten to
return books on date and sometimes they can be forgotten the books which member
borrowed. When I provide this email notification facility, librarian doesn’t want to
worry about that, because, this function will be fully automated one. If the member
doesn`t return books on date, email will generate and send to the member
automatically. The other one is SMS. Short message service is also speed way to
spread notifications. Because, in present we all have a mobile device. It has become a
very common device.

Mohammed Basith Programming with Java 108


4.4 Create user documentation for the developed java program solution.

READ WITH US
Library Management
System

(LMS)
User Manual

Mohammed Basith Programming with Java 109


Table of Content

1 Introduction

2 Installing the software (LMS)

2.1 Hardware and Software

2.2 Initial installation

3 User Interface Guide

Mohammed Basith Programming with Java 110


1. Introduction
Read with Us library is the leading library among other libraries in Colombo area.
It has many members. But this library currently use paper based manual system to
record keeping and to perform other day to day activities. Paper based system has
many limitations and problems. library staff has to face all of this problem. So,
they decided to change this manual, old system to computer based system. A
qualified computer based system is always reliable and error free. So, they don`t
want to worry and computer based system handle all the record keeping and
calculations. LMS helps them to handle all of day to day activities like book
release process, book return process, fines others.

2. Installing the software (LMS)


Library management system can install easily. library staff can implement the
system in few steps. Please follow the install instructions.

2.1. Hardware and software requirements


Before you install this system to your computer, you must fulfill following
requirements. This will have an impact for software`s performance.

Hardware requirements
 Dual Core (1.5Ghz minimum) Processor
 1 GB Main Memory (2 GB Recommended)
 64 MB Video Memory
 80 GB HDD
 DVD Rom/Writer
 UPS

Software requirements
 Windows 7 or Higher
 JRE 1.8 or higher
 WAMP server
 Proper anti-virus(optional)

Mohammed Basith Programming with Java 111


2.2. Initial installation
Install JRE

Figure 23 Configure JRE

 Double click on executable file and click next and select the destination folder to
install JDK.
 Click next to proceed and it will take couple of minutes to install.

Figure 24 Installing JRE

Figure 25 finishing installation

 When this window appears, your JRE installation is complete. Just click close
button.

Mohammed Basith Programming with Java 112


Install WAMP server

Figure 26 WAMP select location

 Double click on WAMP server setup file and click next.


 You can see the above window.
 After selecting this location, click next.

Figure 27 Installing WAMP

 This will take few minutes to finish.

Mohammed Basith Programming with Java 113


Figure 28 Server configuration

 You can change the default server name through this window. (you can use
default)
 And also, you can add your email. (you can use default)
 After that, click next.

Figure 29 Installation finish

 Click close to finish the setup window.

Mohammed Basith Programming with Java 114


 After installation wizard, you should go to the dist folder using following
directory
D:\Others\HND\Java\Netbeans\LIBRARY\dist
 Double click on LIBRARY.jar file.
 Here is the Folder

Figure 30 Execution folder

3. User Interface Guide


3.1. Graphical user interfaces

1. Login 11. Member Main Menu


2. Librarian Main Menu 12. Book (Member)
3. Books 13. Book Release
4. Members (Member)
5. Book Release 14. Overdue
6. Book Return 15. Help (Member)
7. Payment 16. Update User
8. New User 17. Super User Main Menu
9. Fines 18. New User
10. Help 19. Help (Super User)

Mohammed Basith Programming with Java 115


1. Login

Figure 31 Login user interface

 Enter Username and Password.


 Click on login button to log to the system.
 Click on Exit button to close the program.

2. Librarian Main Menu

Figure 32 Librarian main menu

 You can get an idea about books and members, when log on to this.
 User have 09 selections in this window.

Mohammed Basith Programming with Java 116


3. Books

Figure 33 Book interface (librarian)

 You can add, update, search and remove book details through this window.
 When you are searching the record, you can search by book name or author name.
4. Member

Figure 34 Member interface (librarian)

 You can add, update, search and remove member details through this window.
 When you are searching the record, you can search by member name or NIC no.

Mohammed Basith Programming with Java 117


5. Book Release

Figure 35 Book release interface (Librarian)

 Select books using first 02 tables.


 Select member from table.
 You can release books and update details using this window.
 And also, all the table data can search.
6. Book Return

Figure 36 Book Return (librarian)

 Double click on the particular record.


 System will count the date count and fill the text fields.
 If date count is less than or equal 14, you can just click return books button and
simply the particular record will be disappeared. (book returned)

Mohammed Basith Programming with Java 118


 If date count is greater than 14, you have to click pay button. (if you click return
books button, system will show you an error message.)
 You can also search records using member name.
7. Payment

Figure 37 Payment interface (librarian)

 Day count and amount count are fully automated functions. (system will show
those without interference)
 If you click pay button, the particular record will have disappeared. (book
returned.)
 If you click on cancel button, dispose this payment window.

Mohammed Basith Programming with Java 119


8. New User

Figure 38 New user interface (librarian)

 Select the member, you want to create account.


 After entering user name and password, click on add button to create.
 If you want to remove account, double click on particular user account record and
click remove button.
 You can search member and user details.
9. Fines

Figure 39 Fine interface (librarian)

Mohammed Basith Programming with Java 120


 You can see all the payments in this window.
 And also, you can search records using member name.

10. Help

Figure 40 Help interface (librarian)

 You can get information about all the librarian functions, through this window.
11. Member Main Menu

Figure 41 Main menu (member)

Mohammed Basith Programming with Java 121


 User have 06 selections in this window.

12. Book (member)

Figure 42 Book interface (member)

 Member can search book details according to book name or author name.
13. Book Release (member)

Figure 43 Book release interface (member)

 Member wants to select book from above tables.

Mohammed Basith Programming with Java 122


 After that, member can release books.
 But, Member cannot release book, if member has gotten other books without
returning.
14. Overdue

Figure 44 Overdue interface (member)

 Member can get the overdue details through this interface.


 If member has gotten the book, system show the record according to member
name.
 Double click on this record and member can see the day count and fine amount.
15. Help (member)

Figure 45 Help interface (member)

Mohammed Basith Programming with Java 123


 You can get information about all the member functions, through this window.

16. Update User (member)

Figure 46 Update user interface (member)

 Member can update own credentials using this window.


 Member name will load automatically.
 You have to input user name and password manually click on update button.
17. Super user Main Menu

Figure 47 Main menu (super user)

Mohammed Basith Programming with Java 124


 User can select 04 selections through this window.

18. New User (super user)

Figure 48 New user (super user)

 Select the member, you want to create account.


 After entering user name and password, click on add button to create.
 If you want to remove account, double click on particular user account record and
click remove button.
 You can search member and user details.
19. Help (super user)

Figure 49 Help interface (super user)

 You can get information about all the super user functions, through this window.

Mohammed Basith Programming with Java 125


4.5 Create a technical document
Technical Document

 purpose

This technical document describes all the features and requirements of the
newly created library management software. I have created this for
programmers in our side. Therefore, this should be very accurate. And also,
programmers can get a complete idea and this guide to build the software
solution for Read with Us library. Users also use this document to get and
exact idea about system and how to interact with function in the system.

 Introduction
Read with Us library is the good library situated in Colombo area. This is
the very famous and good library. But this library is using the paper base
system to keep records like book details and member details. This paper
base manual system has many limitations and problems. So, Read with Us
library management decided to switch this manual system into automated
computer based system. They hope to solve problems with this automated
system. With this newly created system, they can do their day to day
activities like add members and create user accounts, book releasing, book
returning and payments easily.

 Functions of the system

Mohammed Basith Programming with Java 126


Figure 50 - Functions of the system

 Functional requirements
The Functional Requirements shows the operations and activities that a system
must be able to perform. This is designed to be read by a general audience.
Readers should understand the system, but no particular technical knowledge
should be required to understand the document. I mentioned the functions
available for administrator, librarian and member in here.

Functional requirements of Librarian


 Login - This is primary security step in this system and librarian should enter valid
user name and password to go through this function. Otherwise librarian cannot
access to the system.
 Add books - Librarian can add book details using this function.
 Selecting a record - Librarian wants to select a particular record before update or
remove.
 Update book details - Librarian can modify existing book details using this
function.
 Remove books - Librarian can remove unwanted book details using this function.
 Search books - Librarian can search books according to book name or author
name.
 Add members - Librarian can add member details using this function.
 Selecting a record - Librarian wants to select a particular record before update or
remove.

Mohammed Basith Programming with Java 127


 Update member details - Librarian can modify existing member details using this
function.
 Remove member - Librarian can remove unwanted member details using this
function.
 Search member - Librarian can search members according to name or NIC.
 Release books - After selecting the books and member from loaded tables,
librarian can release books.
 Selecting a record - Librarian wants to select a particular record before update
when needed.
 Update released book details - Librarian can modify existing release book details
using this function.
 Search released books - Librarian can search released books according to member
name.
 Selecting a record - Librarian wants to select a particular record for loading into
text fields when book returning.
 Book return - If the date count is less than or equal 14, librarian should click on
book return button. This button executes the record deletion function.
 Pay - If the date count is greater than 15, librarian should click on pay button.
When this button clicked, system will show another interface with payment details
like amount. This amount calculated by internal function. In payment interface,
there is also a button called pay. When this button hits, add payment details to the
system and delete particular book release record.
 Selecting member for creating user credentials - Librarian want to select a
member for loading member name to the text field.
 Creating user credentials - Librarian wants to add user name and password and
should hit the add button. This button calls add function.
 Search users - Librarian can search users according to user name or member
name.
 Selecting a record - Librarian wants to select a particular record before remove.
 Remove users - Librarian can remove unwanted user accounts using this function.
 Search payments - Librarian can search payments according to member name.
 Log out - Librarian can log out from the system if librarian use this function.
System will show the login screen again.

Mohammed Basith Programming with Java 128


 Exit - Librarian can close whole system by using this function.

Functional requirements of Member


 Login - Member can access to the system using username and password after
creating them.
 Search books - Member can search books according to book name or author name.
 Release books - After selecting the books from loaded tables, member can release
books. But member cannot release books, if the member has released books
without returning.
 Update credentials - Member can update own user name and password using this
function.
 Check overdue - Member wants to select a particular record to check overdue.
After click on record, system will load details into text field automatically.
 Log out - Member can log out from the system if member use this function.
System will show the login screen again.

Functional requirements of Super User


 Login - Super user can access to the system using username and password.
 Selecting member for creating user credentials - Super user wants to select a
member for loading member name to the text field.
 Creating user credentials - Super user wants to add user name and password and
should hit the add button. This button calls add function.

Mohammed Basith Programming with Java 129


 Search users - Super user can search users according to user name or member
name.
 Selecting a record - Super user wants to select a particular record before remove.
 Remove users - Super user can remove unwanted user accounts using this
function.
 Log out - Super user can log out from the system if super user use this function.
System will show the login screen again.
 Exit - Super user can close whole system by using this function.

Non-Functional Requirements
Basically, Non-functional requirements describe how the system works,
while functional requirements describe what the system should do.

Usability
 Users can work with software easily.
 User don’t want to add same details over and over again.
 User can select stored details and just one click.
 All the functions are quick and simple.
 User can perform many functions in one interface.

Portability
 This is windows based system. But I have used java programming language to
build this system. Java is a platform independent language. After creating a jar
file, you can run that jar file in any platform, but it needs JRE to run. So, you have
to install JRE before run it.

Operability
 Users – Librarian, Members and Super user.
 Required Software – Java Runtime Environment (JRE), WAMP server.

Mohammed Basith Programming with Java 130


Security
 All the important data adding part done by librarian. Because it prevents the
interference of unauthorized persons.
 After log in to the system, member can update user details.

Performance
 System functions and database response quickly.
 This system available in anytime.
 Because of using special techniques greatly decreases the dump file count and
because of that system will be fast starting and functioning.

Cultural, Political and Legal requirements


 System compiles all the government rules and conditions.
 According to the agreement, provided the best solution for library.
 There are no any other religion symbols and others.

User Interfaces requirements


 Interfaces are user friendly and eye catching.
 Used good color combination.
 Reduce eye strain in long sessions.

Hardware requirements
 Dual Core (1.5Ghz minimum) Processor
 1 GB Main Memory (2 GB Recommended)
 64 MB Video Memory
 80 GB HDD

Software requirements
 Windows 7 or Higher

Mohammed Basith Programming with Java 131


 JRE 1.8 or higher
 WAMP server
 Proper anti-virus(optional)

Main Inputs to the system


 Book details
 Member details

Main Outputs to the system


 Book releasing records.
 Fine payments
 Access credentials
 View all the entered details

5 Appendix A
5.1 Gantt chart

Table 47 Gantt Chart

Mohammed Basith Programming with Java 132


Mohammed Basith Programming with Java 133
6 Appendix B
6.1 Questionnaire

Figure 51 - Questionnaire

Mohammed Basith Programming with Java 134


7 Reference
Admin (2008) JAVA Tutorial and programming. [ONLINE] Available at:
http://www.Completejava tutorial.com / (Accessed: 9th January 2018).

Agrahari, M. (2016) Introduction to object oriented programming concepts in


Java. [ONLINE] Available at:
http://www.javacorner.com/UploadFile/mkagrahari/introduction-to-object-
oriented pro graming-concepts-in-java/ (Accessed: 9th January 2018).

Bell, D. (2004). The class diagram. [ONLINE] Available at:


https://www.ibm.com/
developrworks/rational/library/content/RationalEdge/sep04/bell/. [Accessed on
17 January 2018]

Bell, D. (2004). The sequence diagram. [ONLINE] Available at:


https://www.ibm.com/ developerworks/rational/library/3101.html. [Accessed on
27 December 2017]

Christiano, M. (2015). What are integrated development environments?.


[ONLINE] Available at:
https://www.allaboutcircuits.com/technical-articles/what-are-integrated -
development-environments/. [Accessed on 9 January 2018]

Silva, N. (2015). Use case diagram tutorial. [ONLINE] Available at:


http://creately .com/blog/diagrams/use-case-diagram-tutorial/. [Accessed on 28
December 2017]

Singh, C. (2013). Introduction to java programming. [ONLINE] Available at:


http://beginnersbook.com/2013/05/java-introduction/. [Accessed on 10 January
2018]

Venners, B. (1998). Exceptions in java. [ONLINE] Available at: http://www.java


world.com/article/2076700/core-java/exceptions-in-java.html. [Accessed on 13
January 2018]

Wielenga, G. (2014). The top 10 NetBeans features according to its users.


[ONLINE] Available at: https:// jaxenter. com/ netbeans/ the- top- 10- netbeans-
features- according- to- its-users. [Accessed on 25 December 2017]

Mohammed Basith Programming with Java 135

You might also like