The document describes a prisoner management system created using Java. It includes UML diagrams like use case, class, activity, and sequence diagrams that were used to design the database and system. The system allows a warden to add, delete, search for, update, and display prisoner records. It also provides prisoner functions like adding, deleting, finding, and releasing prisoners. The source code for the classes and database connection is provided along with sample outputs.
1. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012
APIIT SD INDIA
CE00396-1-OOEDP
Object Oriented & Event Driven Programming
Lecturer
Gaurav Gambhir
Submitted by:
Prince Kumar
Intake no: PT1082219
E-mail id: Pt1082219@apiit.edu.in
1
Asia Pacific Institute of Information Technology
2. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012
ACKNOWLEDGEMENT
The satisfaction that accompanies that the successful
Completion of any task would be incomplete without the
Mention of people whose ceaseless cooperation made it
Possible, whose constant guidance and encouragement
Crown all efforts with success.
We are grateful to our project guide Mr. Gaurav Gambhir
For the Guidance, inspiration and constructive suggestions
that Helpful us in the preparation of this project. We also
thank our colleagues who have helped in successful
Completion of the project.
Prince Kumar
2
Asia Pacific Institute of Information Technology
3. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012
ABSTRACT
“Secure prisons are essential to making our justice system an effective
weapon against crime. When Prisoners – convicted or awaiting trial – are
entrusted to your care, they must know and the public must know that they will
remain there until they are legally discharged …”
Prisoner Management system has never been easier .The prisoner
module provides management tools and reporting specifically design
for modern law enforcement. The security of a prison should go
further than preventing the effective control of communication of
prisoners with the outside world to prevent the continuation of
organized crime, or intimidation of witnesses or victims by
incarcerated prisoners.
This report describes implementation of a Prisoner Management
system. We used the UML Diagrams model to design a database that
will store and organize the Prisoner data. We have created the
database using SQL and populated it with some sample Data. The
system can keep track of Add Prisoner, Delete Prisoner, Find
Prisoner, Release Prisoner, Add Warden, Delete Prisoner, and Find
Prisoner And the relationships between them. Using Awt Java, java
sql and JDBC, we have created an Internet-based graphical user
interface that allows Warden to access the system remotely. This
management system includes two different action first is Prisoner and
second is Warden. They both perform different operation. In which
warden and prisoner are handled. Like user can handle warden by
adding, deleting, updating the status and many more .And in prisoner
user can add, delete, update, find, release, edit. Which we discuss in
further i.e., assignment.
3
Asia Pacific Institute of Information Technology
4. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012
Table of Contents
S.no
1.
Topic
UML Diagram
1.1.
1.2.
1.3.
1.4.
Page no:
5-9
Use case
Class Diagram
Activity Diagram
Sequence Diagram
5
6-7
8
9
2.
Story Boarding
10
3.
Source Code
11-28
4.
Sample Output
29-30
5.
Assumptions
31
6.
Conclusion
32
7.
References
33
4
Asia Pacific Institute of Information Technology
5. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012
1. UML Diagram
1.1 Use Case Diagram...
System
Add
*
Delete
*
Search
*
*
Prisoner
*
*
**
*
*
Update
*
Find
*
Display
*
*
Add
*
*
*
**
Warden
Delete
*
*
*
*
*
Update
Users
*
*
Find
*
Display
*
Exit
5
Asia Pacific Institute of Information Technology
6. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012
1.2 Class Diagram …..
ShowWarden
6
PMS
Asia Pacific Institute of Information Technology
Prisondbase
7. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012
Prisoner
7
showpRecord
Asia Pacific Institute of Information Technology
8. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012
1.3 Activity Diagram …..
Execute Stand Alone
Application
Welcome Frame
Decision
by user
Prisoner
Warden
Add
Add
Delete
Find
Release
Display
8
Asia Pacific Institute of Information Technology
Delete
Display
Warden
9. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012
1.4 Sequence Diagram..
A sequence diagram in a Unified Modeling Language (UML) is a kind of interaction diagram that
shows how processes operate with one another and in what order. It is a construct of a Message
Sequence Chart. A sequence diagram shows object interactions arranged in time sequence. It
depicts the objects and classes involved in the scenario and the sequence of messages exchanged
between the objects needed to carry out the functionality of the scenario. Sequence diagrams
typically are associated with use case realizations in the Logical View of the system under
development.
Sequence diagrams are sometimes called event diagrams, event scenarios, and timing diagrams
Prisoner : Add
Prisoner : Delete
Prisoner : Release
Prisoner : Find
Add
Find
Display Result
Request Display All
Display Records
Find Prisoner
Return Prisoner
Delete and Update
Actor
Return Records
9
Asia Pacific Institute of Information Technology
Prisoner : Display All
10. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012
2.
Story Boarding
For Warden Window
For Closing the
window
For Prisoner
Window
Delete
Search
Add
Prisoner
10
Asia Pacific Institute of Information Technology
Update
Display
23. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012
String sql="SELECT * FROM PRISON WHERE PID LIKE ?";
ptmt=con.prepareStatement(sql);
ptmt.setString(1, txtid.getText());
ResultSet rs=ptmt.executeQuery();
while(rs.next())
{
txtid.setText(rs.getString(1));
txtname.setText(rs.getString(2));
cboseclevel.setSelectedItem(rs.getString(3));
cboddp.setSelectedItem(rs.getDate(6).getDate());
cbommp.setSelectedItem(rs.getDate(6).getMonth());
cboyyp.setSelectedItem(rs.getDate(6).getYear());
cboddr.setSelectedItem(rs.getDate(7).getDate());
cbommr.setSelectedItem(rs.getDate(7).getMonth());
cboyyr.setSelectedItem(rs.getDate(7).getYear());
}
} catch (Exception e) {
e.printStackTrace();
}
}
if(ev.getSource()==btndelete)
{
int i=0;
try {
Connection con3=mydb.getDBConnection();
String sql3 = "UPDATE PRISON SET Status=? WHERE PID=?";
PreparedStatement ptmt3 = con3.prepareStatement(sql3);
ptmt3.setString(1, "Dead");
ptmt3.setString(2, txtid.getText());
i = ptmt3.executeUpdate();
if(i>0)
{
JOptionPane.showMessageDialog(null,"Prisoner Successfully
deletd");
}
else
{
JOptionPane.showMessageDialog(null,"Prisoner Successfully Not
deletd");
}
23
Asia Pacific Institute of Information Technology
24. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012
} catch (Exception e2) {
// TODO: handle exception
e2.printStackTrace();
}
}
if(ev.getSource()==btnupdate)
{
ResultSet rs = null;
int dd, mm, yy;
int totaldaysLeft = 0;
Calendar cd = Calendar.getInstance();
Date dateOfRelese = null, dateDifference = null;
try {
Connection con = mydb.getDBConnection();
String sql = "SELECT * FROM PRISON WHERE PID LIKE ?";
PreparedStatement ptmt = con.prepareStatement(sql);
ptmt.setString(1, txtid.getText());
rs = ptmt.executeQuery();
while (rs.next()) {
dateOfRelese = rs.getDate(6);
}
dd = dateOfRelese.getDate();
mm = dateOfRelese.getMonth();
yy = dateOfRelese.getYear();
con.close();
ptmt.close();
cd.set(yy, mm, dd);
System.out.println(cd);
dateDifference = new Date(cd.getTimeInMillis()
- Calendar.getInstance().getTimeInMillis());
System.out.println(dateDifference);
totaldaysLeft = dateDifference.getDay();
System.out.println("Total days left+"+totaldaysLeft);
if (totaldaysLeft > 7) {
JOptionPane.showMessageDialog(null,
"The Prisoner Could not be released");
} else {
int i = 0;
try {
24
Asia Pacific Institute of Information Technology
25. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012
Connection con1 = mydb.getDBConnection();
String sql3 = "UPDATE PRISON SET Status=? WHERE PID=?";
PreparedStatement ptmt3 = con1.prepareStatement(sql3);
ptmt3.setString(1, "Released");
ptmt3.setString(2, txtid.getText());
i = ptmt3.executeUpdate();
if(i>0)
{
JOptionPane.showMessageDialog(null,
"Prisoner Released Successfully");
}
else {
JOptionPane.showMessageDialog(null,
"Prisoner Couldnot Be Released");
}
} catch (Exception e2) {
e2.printStackTrace();
}
}
} catch (Exception e2) {
e2.printStackTrace();
}
if (rs == null) {
JOptionPane.showMessageDialog(null,
"Prisoner Couldnot Be Found");
}
}
if(ev.getSource()==btndisplay)
{
showpRecord ps=new showpRecord();
ps.setVisible(true);
ps.setVisible(true);
}
}
}
25
Asia Pacific Institute of Information Technology
26. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012
Save as : showpRecord
import java.awt.*;
import javax.swing.*;
import javax.swing.table.*;
import javax.swing.event.*;
import java.awt.event.*;
import java.sql.*;
import java.util.Vector;
public class showpRecord extends JFrame
{
Container c;
DefaultTableModel prisonerTablemodel;
prisondbase db=new prisondbase();
Vector<String> prisonVector;
JTable prisonTable;
showpRecord()
{
c=getContentPane();
setSize(1300,700);
setTitle("Records For Prisoner ");
c.setBackground(Color.white);
c.setLayout(null);
setResizable(false);
String pRecord[]={"Prisoner ID","Name"," Security Level ","Date Of Prison","Date Of
Release","Status"};
prisonerTablemodel=new DefaultTableModel(pRecord,0);
prisonTable=new JTable(prisonerTablemodel);
JScrollPane jspPrisoner=new JScrollPane(prisonTable);
jspPrisoner.setSize(1150, 700);
c.add(jspPrisoner);
try{
Connection con=db.getDBConnection();
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("Select * from PRISON");
while(rs.next())
{
prisonVector=new Vector<String>();
26
Asia Pacific Institute of Information Technology
27. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012
prisonVector.add(rs.getString(1));
prisonVector.add(rs.getString(2));
prisonVector.add(rs.getString(3));
prisonVector.add(rs.getString(4));
prisonVector.add(rs.getString(5));
prisonVector.add(rs.getString(6));
prisonerTablemodel.addRow(prisonVector);
}
st.close();
con.close();
}
catch(Exception e){
System.out.println(e);
}
setVisible(true);
setDefaultCloseOperation(3);
}
}
Save as : showWardens.java
import java.awt.*;
import javax.swing.*;
import javax.swing.table.*;
import javax.swing.event.*;
import java.awt.event.*;
import java.sql.*;
import java.util.Vector;
public class showWardens extends JFrame
{
Container c;
DefaultTableModel WardenTablemodel;
prisondbase db=new prisondbase();
Vector<String> WVector;
JTable WardenTable;
showWardens()
{
c=getContentPane();
27
Asia Pacific Institute of Information Technology
28. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012
setSize(1000,700);
setTitle("Records For Warden ");
c.setBackground(Color.white);
c.setLayout(null);
setResizable(false);
String pRecord[]={"Warden ID"," Name "," Rank "};
WardenTablemodel=new DefaultTableModel(pRecord,0);
WardenTable=new JTable(WardenTablemodel);
JScrollPane jspWarden=new JScrollPane(WardenTable);
jspWarden.setSize(900, 700);
c.add(jspWarden);
ResultSet rs=null;
try{
Connection con=db.getDBConnection();
Statement st=con.createStatement();
rs=st.executeQuery("Select * from WARDEN");
while(rs.next())
{
WVector=new Vector<String>();
WVector.add(rs.getString(1));
WVector.add(rs.getString(2));
WVector.add(rs.getString(3));
WardenTablemodel.addRow(WVector);
}
st.close();
con.close();
}
catch(Exception e){
System.out.println(e);
}
setDefaultCloseOperation(3);
}
}
28
Asia Pacific Institute of Information Technology
29. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012
4. Sample Output
Welcome Form: Prisoner Management System
Prisoner Form
29
Asia Pacific Institute of Information Technology
30. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012
Warden Form
30
Asia Pacific Institute of Information Technology
31. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012
5. Assumptions
Due to limited knowledge the following assumptions were made in the assignment:
validations on the textboxes have not been given, so it has been assumed that the user
enters correct data
lesser class files could have been made
all the functionalities like add, delete, find etc are given on the same page
combo box has not been used to select warden id while adding a prisoner .
31
Asia Pacific Institute of Information Technology
32. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012
6. Conclusion
Finally completing this assignment I came to know more about Object oriented.
I have to implement some of the features of java to design Prisoner management
system. This assignment based on Prisoner management through database.
During the completion of the assignment, I have learned a many new things like
working with swing, action listeners. Now i can create Stand Alone
Application easily. I have become well aware of the following concepts of java:
Arrays
Classes
Objects
Constructors
Inheritance
Exception Handling
Abstract classes
Interface
Polymorphism
Looping
32
Asia Pacific Institute of Information Technology
33. [OBJECT ORIENTED & EVENT DRIVEN PROGRAMMING ,
INDIVIDUAL ASSIGNMENT ] May 2, 2012
7.References
[1] http://www.java-examples.com/ [Accessed on : 1st April,12 ]
[2] http://en.wikipedia.org/wiki/Sequence_diagram [for sequence - definition :
Accessed on : 26th April , 12 ]
[3] Dietel, H.M. & Dietel, P.J. (2001) Java: How to Program, Prentice Hall. (ISBN:
0130341517)
[4] http://docs.oracle.com/javase/1.4.2/docs/api/javax/swing/ [For Layout - Accessed on :
2nd April , 12 ]
33
Asia Pacific Institute of Information Technology