Anda di halaman 1dari 78

Downloaded from www.pencilji.

com
PROGRAM 2: GRID LINES
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

class Design extends JFrame


{
Container cp;
Design()
{
cp=getContentPane();
cp.setLayout(null);
Adapter ad=new Adapter(this);
addWindowListener(ad);
repaint();
}

public void paint(Graphics g)


{
for(int i=0;i<=800;i+=10)
{
g.drawLine(i,0,i,800);
g.drawLine(0,i,800,i);

class Adapter extends WindowAdapter


{
Design dd;
public Adapter(Design d)
{
dd=d;
}

public void windowClosing(WindowEvent we)


{
System.exit(0);
}
}

public static void main(String s[])


{
Design d1=new Design();
d1.setSize(500,500);
d1.setVisible(true);
}

}
1
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com

PROGRAM 3: GRID WITH TWO SETS OF DIAGONAL LINES


import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

class Design1 extends JFrame


{
Container cp;
Design1()
{
cp=getContentPane();
cp.setLayout(null);
Adapter ad=new Adapter(this);
addWindowListener(ad);
repaint();
}

public void paint(Graphics g)


{
for(int i=0,j=1000;i<=1000;i+=10,j-=10)
{
g.drawLine(0,i,i,0);
g.drawLine(i,0,1000,j);
g.drawLine(0,i,j,1000);
}
}

class Adapter extends WindowAdapter


{
Design1 dd;
public Adapter(Design1 d)
{
dd=d;
}

public void windowC losing(WindowEvent we)


{
System.exit(0);
}
}

public static void main(String s[])


{
Design1 d1=new Design1();
d1.setSize(500,500);
d1.setVisible(true);
}
}
2
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com

PROBLEM 4
Proble m definition

In employee referral process, the HR head of the region where a vacancy exists
informs employees of that region and other regional HR heads. The other regional HR
heads inform employees by putting up a notice informing them about the vacancy. The
employees send on their recommendations to the regional HR head of the region where a
vacancy exists. The regional HR head then matches the skills of these candidates with the
skills required for the vacant position and shortlist them. An interview schedule is drawn
up and the short listed candidates are informed. Based on the interview processing,
interview details are updated and all the selected candidates are given offer letter. The
candidate informs the HR (head where the vacancy exists) either by accepting or
declining the offer letter. When a candidate referred by an employee joins the
organization, the employee who has referred the candidate is paid a bonus.

a) Identify various use cases and actors involved and represent the user view of the
system.
b) Identify the various classes and attributes and bring out a class diagram, and a
sequence diagram.

REQUIREMENTS SPECIFICATION

 The process shall result in the recruitment of employees for the vacancy that has
become available in a particular region.

 The total candidates considered for the process shall be made available by a
referral system from the existing employees of the organization.

 The HR head of a particular region shall inform details about the vacancy to
employees of his/her region and also inform the other HR heads of the same
vacancy.

 The references from the other HR heads shall be made available to the region that
has the vacancy.

 The candidates that meet the requirements of the vacancy shall be short listed for
the selection process.

 The interview process is conducted and the candidates are selected to meet the
vacancy of the region.

 The selected candidates are informed and are requested to accept the job offer.

 Based on whether the candidate accepts the job offer bonuses shall be awarded to
the employee that referred the candidate.

3
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com

Actors:
Actors are as follows:
1.HR Head.
2.Employee.
3.Candidates.

Actors Documentation:
1.HR Head:
HR Head is an actor who informs about the vacancy to their employees and also
other regional HR Heads, who in turn informs their respective Employees and also
matches the skills of the referred Candidates with their skills, required for the vacant
position and shortlist them. HR Head is also responsible for Interview Scheduling.

2.Employee:
Employee is an actor who references the Candidates regardless of his/her region
and receives the incentives provided the referred Candidate got selected

3.Candidate:
Candidate is an actor who is referred by an Employee of the Company and applies
for the vacancy. If the Candidate gets selected then they informs the HR Head about the
acceptance or rejection of the offer letter.

4
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com

Use-Case Diagram:

Notify Vacancy

Fill referral Form

<<Uses>>

HR Head
Selection of Eligible
Candidates

<<Extends>> Employee

Interview Process

Intimat ion to Select ed


Ca ndidates

Ac cept/De cline O ffe r


Candidate
<<Extends>>

A ward Bonus

5
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com

USE CASES:

Use Case: Notify Vacancy


Description : This Use Case is initiated by HR and the Employee.
Notifies about the vacancies to employees of the region.
Flow of Events: 1. HR Head sends Email notification to his/her employees.
2. HR Head informs about vacancy to other region HR heads.
3. Other HR heads in turn inform their employees.
Pre-Condition: Vacancy must exist.
Post-Condition: Details about the vacancy are informed.

Use Case: Filling of Forms


Description: This Use Case is initiated by HR and the Employee.
Online forms are filled by the employees.
HR head processes the forms and determines eligible candidates.
Flow of Events: 1. Employees fill out online forms of candidates they want to refer.
2. HR head processes the filled forms.
3. HR heads selects the list of eligible candidates.
Pre-Condition: Online form must exist.
Post-Condition: Forms filled are stored in a Information System for processing.
The filled forms are sent to the HR.
The HR head produces the list of eligible candidates.
.

Use Case: Short Listing of Candidates


Description This Use Case is initiated by Candidate and HR.
The Interviews are conducted by the HR head of the region that has
the vacancy.
The list of selected candidates are obtained after the interview
process.
Flow of Events: 1. HR head schedules the interview process.
2. HR head conducts the interview for the candidates via online
system.
3. Candidates who clear the interview process are selected.
Pre-Condition: Candidate must meet eligibility criteria.
Candidate must be referenced by the employee of that organization.
Post-Condition Candidate clears interview process.
OR
Candidate doesn’t clear interview process.

6
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Use Case : Intimation to the selected candidates.
Description: This Use Case is initiated by the HR Head and the Candidate
The candidate accepts or rejects the offer letter to fill the vacancy.
Bonus is awarded to the employee who referred the candidate.
Flow of Events 1. Candidate is informed about selection the job.
2. Candidate accepts the job offer to fill the vacancy.
3. Bonus is awarded to the employee who referred the candidate.
Alte rnate Flow 1. Candidate rejects the offer letter.
2. Candidate application is rejected.
3. No Bonus is awarded to the employee who referred the
candidate.
Pre-Condition: Candidate is selected for the job.
Post-Condition: Candidate accepts or rejects the offer.
Bonus is awarded to the employee who referred the candidate if
he/she accepts the offer.

Sequence Diagram:
Notify Vacancy:

Email
: HR Head
System : Employee
1: Informs about Vacancy
2.Recieves Vacancy
Information

7
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Fill Referral Process:

Online Form IS
: Employee
: HR Head

1: Refers C andidate

2: Upload Details

3: Refers Candidate

4: Upload Details

5: Retrive the Candidate List

Selection of Candidates:

Online Interview IS
: HR Head System : Candidate

1: Initiate Interview

2: Reply to the Queries

3: Receives reply

4: Stores Shortlisted Candidate Details

8
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com

Intimation [Accepts Offer Letter]:

Email
: HR Head System : Candidate : Employee

1: S ends Offer L etter

2: Receives Offer Letter

3: A ccepts Offer Lette r

4: Recieves Acceptance

5: Informs about bonus awarded

6: Recie ve s B onus Noti fi cation

Intimation [Rejection]:

Emai l : Candidate
: HR Head System

1: sends offer Letter

2: recieves Offer Letter

3: Reject Offer Letter

4: recieves the rejection

9
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com

CLASS DIAGRAM

10
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com

Class Diagram Documentation


Employee:
The employee class is used to store details about the employees of a particular
region. This information shall be used later to award bonuses provided the candidates
they refer get selected to fill the job vacancy.

HR Head:
This class is the main class. The HR is responsible for collecting the details of the
candidates being referred. It is also the HR job to co nduct the interview, shortlist the
candidates and also intimate the selected candidates about the job.

Maintenance:
The Maintenance class is responsible for maintaining the Information System(IS)
where the information about the candidates and the employees are stored.

Vacancy Details:
This class contains the details of the vacancy that are to be filled. Here a Job Code
is assigned to keep information about each vacancy detailing the type of job, the
designation and the No. Of vacant posts.

Candidate:
The candidate class contains the details about the candidates being referred by the
employees. The information about the job they have applied for (Job Code) is also stored.

Selected Candidates:
This class contains the details of the selected candidates after the Interview
process.

Recruited Candidates
This class contains details of the candidates who accepted the offer letters and are
ready to fill the vacancy. This information shall be used to award bonuses to the
employees who referred the candidates.

11
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
PROGRAM 5
Design and implement a student class with the following attributes:
1) Reg No.
2) Name of the student
3) Marks in subject1, subject2, subject3
4) Total Marks
The total of three subject marks must be calculated only when the student pass in all the
subject. The pass marks for each subject is 50. If a candidate fails in any one of the
subjects, his total marks must be declared as 0. Using this condition write a constructer
for this class. Write a method display a student() to display the details of the student of
the object.
a) Identify various use cases and actors involved and represent user view of
the system.
b) Identify various class and attributes and bring out class diagram and
sequence diagram.

Description

In this problem the students interact with the system to see their results. Faculty is the
person who use the software system to enter student’s marks in the system and according
to these marks result is prepared based on the condition that, the total of three subject
marks must be calculated only when the student pass in all the subject. The pass marks
for each subject is 50. If a candidate fails in any one of the subjects, his total marks must
be declared as 0.

Requirement Specification

The system shall accept the marks from the faculty for each student.
The system shall be able to calculate result according to the marks entered and the
condition to declare the result.
Both student and faculty shall see the result.

12
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com

Actors and actor documentation

Faculty: It refers to the person who enters the marks and calculates the result.
Student: The student uses the system to view their result.

Use case diagram

marks processing

<<extends>>

student faculty
result processing

display result

Use case documentation

Marks processing
1. Description: Initiated by the faculty to enter the marks.
2. Precondition: -
3. Normal Flow of Event:
Enter name of the student.
Enter registration number of the student.
Store name and registration number in the database.
Enter marks.
Store marks to the database.
4. Alte rnate flow of event: -
5. Post condition: -

13
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Result Processing

1. Description: Initiated by faculty to evaluate result.


2. Precondition:
3. Normal Flow of Event:
Enter name of the student.
Enter regno of the student.
Search for name and regno from the database.
Retrieve marks from the database and send to the information system.
The total of three subject marks is calculated only when the student pass
in the entire subject. The pass marks for each subject is 50.
4. Alte rnate flow of event: If a candidate fails in any one of the subjects, his total
marks must be declared as 0.
5. Post condition: Store in the database.

Display result

1. Description: Initiated by both student and faculty.


2. Precondition: -
3. Normal Flow of Event:
Enter name of the student.
Enter registration number of the student.
Search name and registration number from the database.
Retrieve result and send to the information system.
Display result.
4. Alte rnate flow of event: -
5. Post condition: -

14
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Sequence diagrams
1. Sequence diagram for marks processing:-

faculty database
Information
Syste...

1: request for regno and name

2: Enter name and regno

3: Save in database

4: Request for marks

5: Enter marks

6: Save marks

2. Sequence diagram for result processing:

faculty database
Information
syste...

1: Request for name and regno

2: Enter name and regno

3: Search for name and regno

4: retrieve marks

5: Provide marks to system

6: Evaluate result and save

15
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
3. Sequence diagram for displaying result:

student database
information
syste...

1: Enter name and regno

2: Search name and regno

3: retrieve result

4: Send result

5: Display result

Cass diagram

Class Documentation

Student:
Student1 class maintains the attributes of student details such as student name reg_no
marks of the three subjects and total marks of those students who have passed in all
the three subjects and use to view the result and detail of the students.

16
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Java code

class student
{
int reg_no;
String name;
int marks[ ]=new int[3];
int total;
student(int r,String n,int m[])
{
reg_no=r;
name=n;
for(int i=0;i<3;i++)
marks[i]=m[i];
for(int i=0;i<3;i++)
{
if(marks[i]>50)
total+=marks[i];
else
{
total=0;
break;
}
}
}
void display()
{
System.out.println("\nReg no : "+reg_no);
System.out.println("NAME : "+name);
System.out.println("Marks in subject1 : "+marks[0]);
System.out.println("Marks in subject2 : "+marks[1]);
System.out.println("Marks in subject2 : "+marks[1]);
System.out.println("Total marks : "+total+"\n");
}

17
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
public static void main(String s[])
{
int a[]={55,67,89};
int b[]={6,90,90};
int c[]={89,87,67};
student ob1=new student(101,"Manu",a);
student ob2=new student(102,"madhu",b);
student ob3=new student(103,"Raju",c);
ob1.display();
ob2.display();
ob3.display();
}
}

18
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
PROGRAM 6
Proble m definition:

Consider the student class defined in Problem 5. Assume that a student studies 6 subjects.
Each subject has a title, passing minimum and maximum marks. Design the class
representation using UML notations and write a java program to define student class
including the subject as attribute.
Design specifications: A student studies 6 subjects. Each subject has a subject code, title,
passing minimum marks, maximum marks.

The following table shows the sample data:

Subject Code Title Passing Min Max. Marks

CS401 Java 50 100


CS406 ASW lab 18 50
-------- --------- ---- ----
You must first define a class called subject. For every student there is an array of 6
subjects. Since all the students study the same subjects, we declare it as static. The student
class will have the following attributes: Reg_no, name, subject array, marks array, result
array and total.
a) Identify the various use cases and actors involved and represent the user view
of the system.
b) Identify the various classes and attributes and bring out a class diagram and a
sequence diagram.

Solution

The purpose of the system is to process marks of individual students in order to determine
whether the particular student has passed or not in the exams and also produce a
formatted report of the same.

The following requirements are identified with respect to the system

 The system shall process marks of the student.


 Based on the mark information provided by faculty the tota l marks of each student
must be obtained along with results.
 Student result details shall be provided in neatly formatted report for viewing.
While calculating the results the following points are conside red
i. A student has to study six subjects, each subject has a passing minimum and
maximum marks.
ii. The total of marks of each student will be calculated only when he/she passes in
all the six subjects.
iii. The passing mark in each subject is 50% of the maximum mark.
iv. If the candidate fails in any one of the subject the total marks is taken to be zero.

 The system must be interactive and suitable user authentication mechanism must
be incorporated.

19
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Actor Documentation

Actors:

 Student: they use the system primarily to check their results.

 Faculty: provides the marks of each student for processing the results.

Usecase Diagram:

LOGIN

STUDENT <<USES>> <<USES>> ENTER MARKS

FACULTY
<<USES>>

VIEW REPORTS MARKS PROCESSING

Usecase documentation:

1 Usecase name: Login

The users of the system either faculty or student interact with the system by going
through a login process to verify their authentication.

Precondition: Each user who wants to use the system must posses a
username & password.
Flow Of Events:
1. Request user name.
2. Enter username.
3. Request password.
4. Enter password.
5. Validate user.
6. If valid continue otherwise go to Alternate flow 1.

20
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Alte rnate Flow
1: Display error message
2: Reenter username and password.
Postcondition: User is allowed or not allowed to login based on the provided username
& password.

2.Usecase name: Marks Processing

Faculty using the system initiates this process. During this stage the total and results of
each student is calculated based on marks entered.
Precondition: Valid marks of each student should be present in order to obtain results.
Flow Of Events:
1. Request register number of the student for whom marks as to
be entered.
2. Enter register number.
3. Validate register number.
4. If valid, perform marks entry process, Otherwise go to
Alternate flow 1.
5. Compute total.
6. Compute Result for the student who’s register number has
been entered.
Alte rnate Flow 1: Display Error Message. Request another register number.
Postcondition: Based on the constraints specified and marks, results of each
student are provided.

3.Usecase name: Marks Entry

Marks of each student are entered by the faculty during this process. Marks entered
during this stage are used while calculating results.
Precondition : Marks are needed to calculate result.
Flow of Events:
1. Request entry of marks.
2. Enter marks.
3. Verify whether entered marks are valid,
If valid continue otherwise Alternate flow 3.
Alte rnate flow 3: Display error message, re-enter marks.
Postcondition: Enter marks are verified and are stored to perform processing.

4.Usecase name: Vie w Reports


Students interact with system for the purpose of determining their results. The results
are presented in the form of reports, for viewing by the students.
Precondition: Students specify their Regno. to view results.
Flow of Events:
1. Request register number of the student.
2. Enter register number.
3. Verify register number.
4. if valid display reports of the result otherwise Alternate
flow 4.
Alte rnate flow 4: Display error message, reenter register number.
Postcondition: Result of the student is displayed in a formatted manner.

21
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com

Sequence Diagrams:
Sequence diagram for Marks entry and Marks Processing

Faculty Database
System :
NewInterface
1: Requrest Regester Number

2: Enter Regester Number

3: Verify

4: Found Valid

5: Request Entry Of Marks

6: Enter Marks
7: Verify Entered Marks

8: Update New Marks

9: Transaction Successful

10: View Message

11: Terminate

22
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Sequence diagram for Login

User System

1: Request user name and password

2: Enter user name and password

3: Not valid

4: Request re-entry

5: Enter user name and password

6: Vali d user

7: Perform operations

Sequence Diagram For Vie wing Reports:-

Student Database
System :
NewInterface
1: Request Register Number

2: Register Number Entry

3: Verify

4: Found Valid

5: Reterive

6: Send Details
7: View Marks Report

23
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Class Diagram

Class Diagram Documentation

1. Class Name: Student

Student class maintains all the attributes indicating the student


details and incorporates the necessary methods required to access
the results, compute results and view reports.

2. Class Name: Subject

Subject class maintains all the details related to subject studied


by the students, the marks details of each Subject.

3.Class Name: Faculty

Faculty operation details are maintained in this class, they login


to the system to enter the mark details of the students based on
the students register number, once entered the marks details are
stored into individual marks array in the student class.

24
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com

Program

import java.io.*;

class Subject
{
static String sub_name[]={"java","c++","ooad","dbms","ooad lab","java lab"};
static String sub_code[]={"Mca51","Mca52","Mca53","Mca54","Mca55","Mca56"};
static int theory_max=100, lab_max=50;
static int theory_min=50, lab_min=25;
// attributes are declared static so they can be accessed without inheritance
}

class Marks_details
{
int sub1[]=new int [20]; // each array contains the marks details of one particular
int sub2[]=new int[20]; // subject, the marks are stored such that each array index
int sub3[]=new int [20]; //corresponds to a students register number
int sub4[]=new int [20];
int sub5[]=new int [20];//first 3 arrays store marks in theory next 2 store lab marks
int sub6[]=new int [20];
void enter_marks()
{
int reg;
try
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter number of student");
String temp=br.readLine();
int n=Integer.parseInt(temp);
for(int i=0;i<n;i++)
{
// Each value of i is used as register number
System.out.println("Enter marks for student with register number " +(i+1) );
System.out.println("Enter marks in MCA51:");
temp=br.readLine();
sub1[i]=Integer.parseInt(temp);
System.out.println("Enter marks in MCA52:");
temp=br.readLine();
sub2[i]=Integer.parseInt(temp);
System.out.println("Enter marks in MCA53:");
temp=br.readLine();
sub3[i]=Integer.parseInt(temp);
System.out.println("Enter marks in MCA54:");
temp=br.readLine();
sub4[i]=Integer.parseInt(temp);
System.out.println("Enter marks in MCA55:");
temp=br.readLine();
sub5[i]=Integer.parseInt(temp);

25
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com

System.out.println("Enter marks in MCA56:");


temp=br.readLine();
sub6[i]=Integer.parseInt(temp);
}
} catch(Exception e){ }
}
}

class Student extends Marks_details


{
String Name;
int reg;
int marks[]=new int[6];
String subject[] = Subject.sub_name; // accessing static attribute sub_name
int total,t;
String result;

Student()
{
reg=-1;total=0;}

int get_details( )
{
try
{
BufferedReader b=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter Register Number");
String s=b.readLine();
reg=Integer.parseInt(s);
System.out.println("Enter Name");
Name=b.readLine();
}catch(Exception e){}
return (reg);
}

void get_marks()
{
marks[0]=sub1[reg-1]; //marks from sub array are stored into marks array
marks[1]=sub2[reg-1]; // the regno value r corresponds to the index in
marks[2]=sub3[reg-1]; // sub array where marks of this regno will be stored
marks[3]=sub4[reg-1];
marks[4]=sub5[reg-1];
marks[5]=sub6[reg-1];//array positions marks[4], marks[5] represent lab marks
}

26
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
void compute_result()
{
int f1=0, f2=0;
for(int i=0;i<6;i++)
{
total=total+marks[i];
}
t=total;
total=0; //reset total
for(int k=0;k<4;k++)
{
if(marks[k]< Subject.theory_min)
f1=1;
}
if(marks[4]<Subject.lab_min || marks[5]<Subject.lab_min)
f2=1;
if(f1==0 && f2==0)
result="PASS";
else
result="FAIL";
}

void show_report()
{
System.out.println("\n"+"_____________________________" + " Student
MarksDetails"+ " ___________________________" );
System.out.println("\n" + "Name: " +Name +"\n" +"Reg: " +reg);
System.out.println("Sub_code Title Pass_Min Pass_max Marks");
for(int i=0;i<6;i++){
if((i!=4)&&(i!=5))
System.out.println (Subject.sub_code[i] +" \t\t " +subject[i] + " \t\t "
+Subject.theory_min +"\t\t" +Subject.theory_max +"\t" +marks[i]);

else

System.out.println (Subject.sub_code [i] +" \t\t " +subject[i] + " \t "


+Subject.lab_min +"\t"+"\t"+Subject.lab_max+"\t"+marks[i]);
}
System.out.println("Total: " +t);
System.out.println("Result :" +result+"\n");
}
}

27
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com

class program6
{
public static void main(String args[])
{
int ch=0;
Student sob=new Student();
try
{
do
{
System.out.println("Enter Type of user");
System.out.println("1. Student");
System.out.println("2. Faculty");
System.out.println("3. Exit");
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter your choice");
String temp=br.readLine();
ch=Integer.parseInt(temp);
switch(ch)
{
case 1: int x=sob.get_details();
if(sob.sub1[x-1]==0)
{
System.out.println("Reg doesnot exist");
break;
}
sob.get_marks();
sob.compute_result();
sob.show_report();
break;
case 2:
sob.enter_marks();
break;
}
}
while(ch!=3);
}catch(Exception e){ }
}
}

28
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com

Problem: 7

A class called Television has the following attributes make, screen, size, purchase
date, color/black & white. Define a method for displaying attribute values of a TV.
Represent this following specification using UML class notations and write a java
program for the same. Television class should be designed with the required attributes.
The main method should be written to test methods of television class. For example
display TV() method may be used to print the attributes of television class.
a) Identify the various use cases and actors involved and represent the user view of the
system.
b) Identify the various classes and attributes and bring out a class diagram and sequence
diagram.

Requirements

1. The system should be able to display all the kinds of models available according to
particular made (Sony, Samsung…).

2. It should be able to show the stock available based on brand, size, color/black & white
ad cost.

3. The user must be authenticated to use the system .

4. The system should be able to display the price list based on the customer
Specification.

Actors

Ope rator:
He is the actual user of the system. He interacts with the system to perform
transactions such as checking availability of models according to customer specification
and displaying price list according customer request.

29
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
JAVA CODE
class TransactionManager
{
String Id="msrit";
String password="msrit";
bool Verify(String user,String pass)
{
return(user.equals("msrit") && pass.equals("msrit"));
}
}
class Television
{
String make,date,type;
int size;
Television()
{
try
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the make:");
make=br.readLine();
System.out.println("Enter the size of T.V.");
size=Integer.parseInt(br.readLine());
System.out.println("Enter the date of manufacturing:");
date=br.readLine();
System.out.println("Enter the type");
type=br.readLine();
}catch(Exception e) { }
}
void display()
{
System.out.println("Information about the T.V.");
System.out.println("--------------------------");
System.out.println("Make of T.V.:"+make);
System.out.println("Date of Manufacturing:"+date);
System.out.println("Type of the TV:"+type);
System.out.println("Size of The TV:"+size);
}
public static void main(String s[])
{
Television t=new Television();
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String user,pass;
TransactionManager tm=new Transactionmanager();
System.out.println("Enter userid");
user=br.readLine();
System.out.println("Enter password");
password=br.readLine();
if(tm.verify(user,pass))
t.display();
else
System.out.println("Invalid userid/password");
}
}

30
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Use cases

Use case name: Display TV models

Description: This use case is initiated by operator. The details are obtained from an
existing database and display different Television models available according to
particular made, screen size...Etc.
Normal flow of events : 1. request for details of T.V .
2. request for specific model .
3. enter the specific models.
4. display the requested models .
Precondition: The models details must exist in the database.

Post condition: Display the models requested.

Use case name: Authentication:

Description: This use case is initiated by operator of the television system. If an operator
enters his/her details like operator name, password the system validate the operator for
using the system.
Normal flow of events : 1. Request for access.
2. Request for Id
3. Enter Id.
4. Request for password.
5. Enter the password.
6. if invalid password or id, go for alternative flow.
Alte rnative Flow : 1.Display the error message
2. Ask for id and password again.
Precondition: Operator information must exist.
Post condition: Access to the television system must be granted.

Use case name: Vie w price list

Description: This use case is initiated by operator of the television system. This usecase
displays the price list of the models selected by the customers.
Normal flow of events : 1. Request for the price list.
2. Request for the specific model.
3. Enter the specific model.
4. Display the price list.
Precondition: Prices of all models must exist.
Post condition: Price list of the specified model is displayed.

31
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com

Usecase Diagram

Display TV Models

<<uses >>

Operator
Aut hent icat ion

Display Price List

Classes

Television Class:

This class has properties tv make, size, purchase_date,color.


Make specifies companies name,size specifies size of the television screen,color
specifies whether the TV is black & white or color.
Methods:
TV() is a constructor used to initialize attributes.
Displays() displays the attribute values.
Check() verifies whether the made,size is available for the customer.

32
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Transaction manager:

Transaction manager class is responsible for authenticating the users.It contains


attributes such as userid and password.
Methods: verify () verifies whether the user is authorized to the system.

OO Testing

There are several ways object-oriented programming can have an impact on testing.
Depending on the approach to OOP

Some types of faults become less plausible not worth testing for).
Some types of faults become more plausible Worth testing now).
Some new types of faults appear.
When an operation is invoked, it may be hard to tell exactly what code gets exercised.
That is, operation may belong to one of many classes. Also, it can be hard to determine
the exact type or class of a parameter. When the code accesses it, it may get an
unexpected value. The difference can be understood by cons idering a conventional
function call.
X=func(y);
For conventional software, the tester need consider all behaviors attributed to func and
nothing more. In an OO context, the tester must consider the behaviors of base::func(), of
devired::func(), and so on.

Sequence diagrams
Authentication:

Operator Television Info


System

Request for Access

Request for Id and Pas sword

Enter Id and Password

Acces s Granted

33
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com

Display TV models:

Operator Television Info


System

Request for details of TV

Request for Specific Made

Ent er Specifi c Made

Di spl ay Model

Display price list

Operator Television Info


System

Request for Price List

Request for Specific Model

Enter the Model

Di spl ay Priceli st

34
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Program 8
Bank Interest Computation

Consider the following attributes:


P : Principle Amount
R : Rate Of Interest
N : Number Of Years
SI : Simple Interest
A : Amount

Requirement Specification:

 Customer deposits money in the bank. The deposited money is called the
Principle Amount.
 After authentication and verification of the user, the principle amount and interest
is computed and the amount is displayed.
 The time in years varies for RD, FD, SB account types and interest is computed
based on the following factors: -
 Account Type: RD, FD, and SB.
 Time duration: Monthly, quarterly, half yearly and annually.
 Minimum Balance: 5000/- SB
10,000/- FD
10,000/- RD

Actors:

 Account Holder
 DBMS
 Administrator

Actor Documentation:

 Account Holder: He or She will have an account in the bank and would be
allowed to access the details of their account.
 DBMS: It will contain the account holder details. It will display the requested
information.
 Administrator: He will authorize the access to the account and if verified will
provide the account details. He will authenticate, validate, compute, update the
interest rates and store the computed results and account holder details in DBMS.

35
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
USE CASE :

Verify Account

D eposi t Administrator
Account
Holder

Calculate Interest

DBMS

Display

Use Case documentation:

 Verify Account: This use case is initiated by the Account Holder, Account Holder
enters the PIN number.This would be cheked by the administrator fro its existence
and correctness and will authenticate the user fro further use of the system.

 Deposit Amount: This use case is initiated by the account holder. The account
holder will deposit the money using the cheques.

 Calculate Interest: This use case is initiated by the Administrator after the
authentication of details provided by the account holder. It will then calculate the
interest amount according to the factors mentioned in the requirements
specification and according to the formulae:

SI = ( P * R *N ) / 100
Amount = P + SI
Where
P : Principle Amount
R : Rate Of Interest
N : Number Of Years
SI : Simple Interest
A : Amount

 Display Output: This use case is initiated by the DBMS. It will display the
account holders’ information on the screen after the processing has been done by
the administrator.

36
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Flow of events:
Verify Account :

Pre-condition:
The Account Holder should have a PIN number.
Normal Flow:
1. Requested for the PIN number.
2. Enters the PIN number. If invalid alternate flow 1
3. The Administrator checks with the Database if the requested PIN number
exists. If it is invalid go to Alternate Flow 2.
4. If valid, it will ask the account holder to deposit money.
Alte rnate Flow 1:
Requested pin number again.
Alte rnate Flow 2:
1. Request the user to enter valid PIN. Go to Normal Flow 2.
2. If again invalid PIN then come out of the transaction.
Post-Condition:
The PIN number is validated and the user is requested to start the required
transaction.

Deposit Money:

Pre-Condition:
The account is validated.
Normal Flow:
1. Enter the cheque number.
2. Enter the branch.
3. Enter the Amount.
4. If cheque is valid, balance is updated.
5. If invalid, go to Alternate Flow 1.
Alte rnate Flow:
1. Balance remains unchanged.
Post-Condition:
The amount is deposited to the respective account type and balance is updated.

Calculate Inte rest:

Pre-Condition:
The minimum balance should be there.
Normal Flow:
1. Enter the account type.
2. Enter the principle amount.
3. Enter the rate of interest.
4. Enter the number of years.
5. If it is less than minimum balance go to Alternate Flow 1.
6. Calculate the Simple Interest according to the formulae:

37
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
SI = ( P * R * N ) / 100
Amount = P + SI

Where
P: Principle Amount
R: Rate Of Interest
N: Number Of Years
A: Amount
SI: Simple Interest
a. The interest is computed and the balance is updated.
Alte rnate Flow:
1. Display “ No minimum balance”
Post-Condition:
The Simple Interest is calculated and balance is updated.

Display Output:

Normal Flow:
1. The updated current balance is displayed on the screen by the
DBMS to the user.
Alte rnate Flow:
No Alternate Flow.
Post-Condition:
The Transaction is successful and completed.

CLASS DIAGRAM

38
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com

Class Documentation :

Account Holder - Account holder class will have the essentials details of the account
holder. The details are Account holder’s name, address, phone number, the account
number which will be an unique number for each account holder, Pin number. The pin
number is known to the account holder.

Administrator - Administrator class will have the details of account holder number,
Account holder name and the Rate of interest needed to calculate the Simple Interest .
The account number is used by the administrator for verifying the account ho lder.

Deposit - Deposit is a class which will have the details of the principle amount of the
account holder, Rate of Interest, the time in number of years. The Simple Interest is going
to be added to the principle and will be known as the amount.

39
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Java code
import java.io.*;
import java.lang.*;

class AccountHolder
{
String name;
int accno;
float balance;

void GetDetails()
{
try
{
BufferedReader BR = new BufferedReader( new
InputStreamReader(System.in));

System.out.println("Enter Name ... :");


name = BR.readLine();

System.out.println("Entet Account No ... :");


accno = Integer.parseInt(BR.readLine());

System.out.println("Enter Main Balance ... : ");


balance = Float.parseFloat(BR.readLine());
}
catch(Exception e)
{
System.out.println(e);
}
}

void ShowDetails()
{
System.out.println(" Account Holder Name : " + name);
System.out.println(" Account Number : " + accno);
System.out.println(" Account Balance : " + balance);
}
}

class Deposite extends AccountHolder


{
float DepositeAmount;
float Rate;
float SimpleInterest;
int Year;

40
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
void CalculateInterest()
{
try
{
BufferedReader BR = new BufferedReader( new
InputStreamReader(System.in));

System.out.println("Enter Amount To Be Deposited ... ");


DepositeAmount = Float.parseFloat(BR.readLine());

System.out.println("Enter No. of Years ... ");


Year = Integer.parseInt(BR.readLine());

System.out.println("Enter Rate of Interest ... ");


Rate = Float.parseFloat(BR.readLine());

balance = balance + DepositeAmount;

System.out.println(" Account Balance after Deposit : " + balance);

SimpleInterest = ((balance * Rate * Year)/100);

balance = balance + SimpleInterest;


}
catch(Exception e)
{
System.out.println(e);
}
}

void ShowAmount()
{

System.out.println(" Deposited Amount : " + DepositeAmount);


System.out.println(" Simple Interest : " + SimpleInterest);
System.out.println(" Updated Balance : " + balance);
}
}

class CalculateInterest
{
public static void main(String args[])
{
Deposite D1 = new Deposite();
D1.GetDetails();
D1.ShowDetails();
D1.CalculateInterest();
D1.ShowAmount();
}
}

41
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com

9. OOA AND OOD USING RAUMBHAG AND UML VI

In a bank the customer opens an account and in that account he/she deposits
money. So the entities are:

CUSTOMER ACCOUNT DEPOSIT

A customer can have several accounts and several customers can spend an account
as a joint account. In the customer class, the address of the customer is const ructed as an
object of a class called Address. Write the UML class diagram consisting customer class
and address class. In the account class there is an attribute called users. This is an integer
attribute. It tells number of users of the account. If the account is a joint account by 5
persons, the value of users =5 persons, the value of users=5. If it is a single user account,
users=1.
Write the UML class diagram for account:
The account number is long type. Cust () is an array of length=users. If the
users=5, cust () is of length 5. Another attribute of the account is an object of deposit
class. Write the UML class diagram for deposit.

TEST CASE:

Object User ID Fname Uname DOB ADD Phone no


name

Address

Object Street City State Country Pin code


name

Deposit:
Principle p=
No. of years n=
Rate of interest=
Account:
Account object: a1
A/c No:
Customer object:
No. of users:
Deposit object: d1
Sample Output:
A/c No:
Custome r ID:
First name:
Last name:
DOB:
Address:
Phones:

42
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Custome r ID:
First name:
Last name:
DOB:
Address:
Phones:

No of users:
Deposit:
Principle:
Rate of interest:
No of years:
Simple interest:
Amount:

Proble m State ment:

In a bank customer opens a account and in that account he/she deposits money.
Customers have several accounts.
Several customers can use an account as joint account.
The above two conditions should be differentiated and the number of users of
those account should be indicated.
Write UML class diagram consisting customer class and address class. In account
class there is an attribute called user of integer type. This tells the number of
users.
If the joint account is by 5 persons the value of users =5.
If it is a single user account then user=1.
Write UML class diagram for account.
The account number is of long type
Cust () is an array of length users. If user=5 then cust() is of length 5.
Another attribute of account is an object of deposit class.
Write UML diagram for deposit.

Requirements:

1 The bank client must be able to deposit amount into his/her account.
2 Recorded transaction must include date, time, amount and account balance after
transaction.
3 Customers can have more than one account.
4 The bank application operates for single banking institutions only.
5 Client’s deposits money called principle amount into the bank and specify the
amount to be deposited for number of years based on that the rate of interest is
calculated.
6 The system must be able to get number of customers at any time.
7 The system must provide security.
8 There are three types of accounts they are savings, current and joint.
9 More than one customer can share account.

43
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
IDENTIFICATION OF ACTORS:

Actors:
1) Clerk
2) BIS

ACTOR DOCUMENTATION:

Clerk:
This actor is responsible for processing the client request, authentication and
carrying out the transactions of the client.

BIS:
This actor is responsible for holding the details of various transaction of the client.

USE CASE DIAGRAM:

Interest Calculation

Clerk BIS

Deposit Money

USE CASE DOCUMENTATION:


(1)

USE CASE NAME : DEPOSIT MONEY

DESCRIPTION This use case is initiated by bank clerk


Bank client deposits money (cash) at random time.
Under the account type we have Joint, Saving and
current
PRE-CONDITION Verification and validation of account number,
user id authenticated by clerk through BIS.

44
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
NORMAL FLOW 1.Enter account number
2.Valid account number
3.Enter customer id.
4.Valid customer id.
5.Enter amount for deposit (cash).
ALTERNATIVE FLOW Not authenticated.
POST CONDITION Update of transaction.

(2)

USE CASE NAME : INTEREST CALCULATION


DESCRIPTION This use case is initiated by bank clerk. It
calculates the simple interest and updates the
balance amount.
PRE-CONDITION Verification and validation of account number,
user id authenticated by clerk through BIS.
NORMAL FLOW Calculation of simple interest.
ALTERNATIVE FLOW Not authenticated.
POST CONDITION Update Balance.

CLASS DIAGRAM :

Analysis Phase:

45
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com

Design Phase:

Class Diagram Description


Class Customer:
This class contains the customer’s personal details like customer identification number,
name of the account holder, his address and date of birth. It will display the customer’s
details on request.
Class Account:
This class contains the account details of the customer like account number, if it is a joint
account then the number of users, date of opening the account and the amount deposited.
This displays the number of users and the amount deposited on request.
Class Address :
This class contains the address details of the customer where is location is recorded as a
proof of existence. This displays the address details of the account holder on request.
Class Deposit :
This class contains the deposit details of the customer with respect to a particular account.
Here we calculate the simple interest based on the principal, number of years deposited
since the last time and interest, which is fixed by the bank. This displays the bank interest
calculated on a particular account.

46
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Problem No: 10
Consider the object college of mini project for the entire given specificatio n in the
problem construct following UML diagrams.
Specification: In a college of CS there are computer laboratories and equipments.
Develop a system to create the college as an object and display contents.
1. Class Diagram
2. Object Diagram
3. Interaction Diagram
a) Sequence Diagram
b) Collaboration Diagram
4. Deployment Diagram

Requirements:

 The system shall display the equipment details of the computer laboratory
of college.
 The maintenance person shall update the details of the laboratory
equipments in college.
 The user shall be allowed to view the details of equipments in college.
Actors:

1. Lab User
2. Maintenance Person
3. Database

Actor Documentation:

1. Lab User: User is an actor who views the details of the laboratory
equipments.

2. Maintenance person: Maintenance person is an actor who updates the


information about the equipments.

3. Database: Database is an actor, which contains the details of laboratory


equipments.

47
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com

Use Case Diagram:

Authentication
Database
Maintenance
person <<uses>>

Update

User View details

Use Case Documentation:

Authenticate: The maintenance person initiates this Use case. The maintenance person
enters the login id and password. If the login id and password are valid the maintenance
person is allowed to update information and view the database.
Flow of events:
1. Request ID
2. Request Password
3. Enter ID
4. Enter Password
5. Verify ID invalid go to alternate flow
6. Verify Password invalid go to alternate flow
Alte rnate Flow:
1. Request ID
2. Request Password
3. Enter ID
4. Enter Password
5. Verify ID
6. Verify Password
Precondition:
The maintenance person shall be provided with a login- id and password.
Post condition:
The valid user is allowed to update the information.

48
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Update: This Use case is initiated by the maintenance person. The maintenance person is
allowed to update the database.
Flow of events:
1. Request for details
2. Enter name and description
3. Update database
Precondition:
The database has to be created.
Post condition:
The details has to be stored into the database.

Vie w details : This Use case is initiated by general user. User is allowed to view the
details of the lab.
Flow of events:
1. Request lab details display form
2. Show form
Precondition :
The equipment details has to be present in the database.
Post condition:
The equipment details is displayed by the system

Sequence diagrams:

1. Sequence diagram for authentication:

Maintenance Database
: loginForm
person
1: Enter id and password

2: Verify

3: Verification

4: Valid user

49
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
2. Sequence diagram for Update:

Maintenance Database
person
: maintenanceForm
1: Enter id & password
2: Verify

3: verification

4: Valid User

5: Request details

6: Enter details

7: Update details

3. Sequence diagram for Vie w details:

User Database

: vi ewdetai lsForm
1: Request details

2: Check database

3: Retrieve

4: Send details

5: Display details

50
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Collaboration diagrams:
1. Collaboration diagram for Authentication:
1: Request details
User

5: Display details
: viewdetailsForm

4: Send details
3: Retrieve
2: Check database

Database

2. Collaboration diagram for Update:


5: Request details
Maintenance
person

: maintenanceForm 1: Enter id & password


6: Enter details
2: Verify
7: Update details
4: V ali d User

3: verification

Database

3. Collaboration diagram for Vie w details:


1: Request details
User

5: Display details
: viewdetailsForm

4: Send details
3: Retrieve
2: Check database

D atabase

51
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Class diagram:

Class diagram docume ntation:

The various classes involved here are:


1. Software class
2. Lab class
3. Peripherals class
4. Equipments class

Software Class: The attributes here are license, No of copies and validity.
Lab Class: The attributes here are Lab- id, which is meant for identification of labs.
Peripherals Class: The attributes here are Make and Type.
Equipment Class: The attributes here are Equipment-Id, Purchase-date and Warranty.

Deployment diagram:

Database Client Machine


Server
LAN

Deployment diagram docume ntation:

Database will be stored in the server and will be accessed by the user through LAN.
52
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Program11:
C Library Information System

Proble m State ment:

A Library lends books and magazines to member, who is registered in the system. Also it
handles the purchase of new titles for the Library. Popular titles are bought into multiples
copies. Old books and magazines are removed when they are out or date or in poor
condition. A member can reserve a book or magazine that is not currently available in the
library, so that when it is returned or purchased by the library, that person is notified. The
library can easily create, replace and delete information about the tiles, members, loans
and reservation in the system.

Requirement Specification

The Library System offers the following Services:


Issuing of Books and Magazines to member who are registered in the system.
It handles the purchase of new titles for library. Popular titles are bought in
multiple copies.
Old books and magazines are removed when they are out of date or in poor
condition.
If a member asks for a book/magazines then
o The book is issued if available
o Otherwise, it is reserved for that member so that he can get the book when
book is available.
It shall provide the loan for purchasing book for student
It shall provide a way to create, replace and delete information about book titles,
member, loans and reservation in the system.

Use-case Documentation

1) Notify: The librarian initiates this use case when any member returns the book
and checking if the book is already reserved.

Precondition: The member should return Book.


Normal Flow: Build message for member who reserved the book.
Post Condition: Send message to respective member who reserved the book.

2) Borrow Book: Initiated by librarian when any member wants to borrow the
desired book. If the book is available, the book is issued.

Precondition: Member should be valid member of library.


Normal Flow: Selected book will be issued to the member.
Alte rnative Flow: If book is not available then reserved book use case should be
initiate.
Post Condition: Update the catalogue.

53
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com

3) Reserve Book: Initiated by librarian when the requested book is not available in
the library at that moment. The book is reserved for the future and issued to the
person when it is available.

Precondition: Initiated only when book is not available.


Normal Flow: It reserved the book if requested.
Post Condition : Mention the entry in catalogue for reservation.

4) Return Books: Invoked by the librarian when a member returns the book.

Precondition: Member should be valid member of library.


Normal Flow: Librarian enters bookid and system checks for return date of the
book.
Alte rnative Flow: System checks for return date and if it returned late fine
message will be displayed.
Post Condition: check the status of reservation.

5) Check library card: The borrow and return use-cases use it to check the validity
of the user-card.

Normal Flow: Enter the memberid.


Alte rnative Flow: system will going to validate the member and if member is not
valid message will be supplied.
Post Condition: Then depending upon the transaction (i.e. borrow or return book)
system will initiate corresponding operation.

6) Add Books: The purchase book use-case when new books invoke it or magazines
are added to the library.

Precondition: Not available or more copies are required.


Normal Flow: Enter bookid and no of copies.
Post Condition: Update the information in catalogue.

7) Remove Book: Initiated by the Library Inventory Manager when old and
damaged books are removed from the library.

Precondition: Books are in the outdated condition.


Normal Flow: Remove the book from library.
Post Condition: Update the catalogue.

54
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com

USE CASE DIAGRAM FOR LIBRARY

Notify
<<Uses>>

Check Library Card


Borrow Books & Magzines
<<extend>>

<<Uses>>

LIBRARIAN Reserve Books

Return Book

Add Book LIBRARY


INVENT...
Remove Book

Actor Documentation

1) Librarian: The Librarian is a person who is responsible for maintaining,


issuing/renewal and reserving of the books. This person also verifies the user’s
library card before issuing, renewing, reserving or accepting a book when
returned.

2) Library Inventory Manager: He/she is responsible for maintaining the library


database by adding and removing the books and their related details as required.
He/she is also responsible for placing orders with the supplier and updating the
database according to the corresponding changes made.

55
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com

Sequence diagram for removing book

Lib Inventory Lib Info


Manager System
1: Query For Outdated / Damaged Books

2: Check for damage

3: display damaged book_id

4: Delete

Collobration diagram for removing the book

2: Check for damage


4: Delete

Lib Inventory
1: Query For Outdated / Damaged Books
Manager

Lib Info
3: display damaged book_id System

56
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com

SEQUENCE DIAGRAM FOR BORROWING BOOKS

Librarian Lib Info


System
1: Verify Id

2: Get File

3: Valid User

4: Get book_id

5: Update

6: Issue Book

Collobration diagram for borrowing the book

Librarian

1: Verify Id 2: Get File


4: Get book_id 5: Update

3: Valid User
6: Issue Book
Lib Info
System

57
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com

DIAGRAM FOR RESERVE BOOKS

Librarian Lib Info


System
1: Verify Id

2: Get File

3: Valid User

4: Get book_id

5: Check for availability

6: Display Unavailable

7: request for reserve book

8: Reserve

COLLOBRATION DIAGRAM FOR RESERVE

Librarian

1: Verify Id
4: Get book_id
7: request for reserve book
2: Get Fi le
5: C heck for availability
3: Valid User 8: Reserve
6: Display Unavai lable

Lib Info
System

58
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com

Sequence diagram for return books /Notify

Librarian Lib Info


System
1: Verify Id

2: Get File

3: Valid User

4: Enter book_id

5: Check for return date

6: Display fine(late return)

7: Check for reservation

8: Notify if reserve

COLLOBRATION DIAGRAM FOR RETURNING BOOKS

Librarian

1: Verify Id
4: Enter book_id 2: Get File
5: Check for return date
7: Check for reservation
3: Valid User
6: Display fine(late return)
8: Notify if reserve

Lib Info
System

59
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Activity diagram for library

Verify Id

[ Valid Member ] [ invalid ]


[ Return book ]
Book_id
[ Borrow book ] Not a Valid
Enter User
book_id
Update &check
for fine
Book [ No ]
Reserve
Available Book
[ Yes ]
Check for
reserve Issue Book
and Update

Class Diagram

60
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com

Class Documentation

1) Catalogue: It is main class contains all details about books and magazines and
made up of two sub class Book and Magazines i.e. Aggregation relationship

2) Book: It is sub class of catalogue it uses the method such as


Add(),Delete(),Search(),Display() of catalogue class and it also have one attribute
Isbn and contains one method Condition() which show the condition of book for
removing purpose.

3) Magazines: Is is also sub class of catalogue it also uses all the method of
catalogue class and contains one attributes Type which describes the type of
magazines.

4) Transaction: Its main class contains the inheritance relationship with Borrow and
Return book.

5) Borrow Book: Contains details about the borrow book that is which member
Borrow particular book and its return date.

6) Membe r: Contains all the information about member such as name,address,


The no. of book particular member has etc.

Component Diagram

Transaction Member

Catalogue

Transaction: This Component consists of Borrow, Return class.

Membe r: This component consists Member class

Catalogue: This component consists of Book and Magazines Class.

61
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com

Program-12:
Develop the product using java programming language. Write UML
diagram for Railway Reservation System.

Requirement specification

The Automated Railway Reservation System offers the following services:


 It is a software used by Railway reservation staff.
 It shall provide train schedules and information
 It shall provide availability of seats on given dates and given train names
 To provide information about category (classes) of tickets like A/C, I class ,II
class, II class sleeper coach
 Customers/passenger to fill the reservation form manually and give it to the
concerned railway staff.
 After processing the customer/passenger information, the staff will verify
availability of the tickets. If it is available the customer/passenger has to pay the
ticket amount by cash to the railway staff. After the amount is paid the staff issues
the ticket to the passenger. Here we assume that no Waiting list ,RAC, tathkal
tickets are issued , Cancellation of tickets are also not available.
 Updating information and availability of tickets taken care by by the railway staff

Use case diagram:

Railway Reservation System

updating information and


display availability of tickets

<<uses>>
Railway
Reservation staff
Database
Train Information

Processing Reservation form

<<extends>>

issuing of tickets

62
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Actors:
Railway Reservation Staff
Database
Description of Actors:

Railway Reservation Staff:


He /she is responsible for processing the passenger’s request like checking the
availability of trains, booking the tickets and issuing of tickets.

Database:
It is used to store, access and keep the updated records of reservation and
information about passenger, and trains. Database keeps track of the seats availability of
respective trains on respective dates.

Use Case Description

1. Train Information:

Description of use case:


The railway staff enters train information like tra in no., train name, date of
journey, source and destination station. It checks the source and destination of trains and
timings of train.
Normal flow of events:
1. Enter the source station
2. Enter the destination station
3. Enter the Train no.
4. Enter the Train name.
Post condition: select the train to journey.

2. Availability Of Ticket:

Description of use case:


The staff initiates this use case. For this the passenger is requested to fill a
prescribed form containing details of train no., train name, date of journey, source and
destination station, class, then it check if the required seat is available or not.
Pre condition: The customer will fill the required form and give it to the concerned
staff.
Normal flow of events:
1. Enter the source station.
2. Enter the destination station.
3. Enter the class of coach.
4. Enter the date of journey.
5.Enter the train no.
6.Enter the train name
7. If the reservation is available, display the details.
Otherwise go to Alternative flow1.
Alte rnative Flow 1: Display that the reservation is not available.

63
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com

3. Processing Reservation Information:


Description of use case:
The passenger is required to enter the train no., train name, date of journey, source
and destination station, class, and no. Of seats, name, age, sex, address. Fill the required
information of ticket along with personal information.
Pre-condition: Seats should be available.
Normal flow of event:
1. Enter the train name and train no.
2. Enter the source station.
3. Enter the destination station.
4. Enter the date of journey.
5. Enter the class of coach.
6 . Enter the Name.
7 . Enter the Age.
8 . Enter the Sex
9. Enter the address
10.Verify the details. If valid details pay the required
amount in cash otherwise Alternative flow 1

Alte rnative Flow 1: Display the details to re-enter the missed details.
Post-condition: The customer will be issued the ticket.

4. Issuing ticket:

Description of use case:


This is an extended use case of processing of reservation information. After the
passenger details are correct the ticket will be given printed form
Pre-condition: Amount must be paid in cash to railway staff
Normal flow of event:
1. Check the details of passenger.
2. Give print message to the printer.
3. The ticket is issued.
4. Database is updated.

Post Condition: The ticket is issued and is collected by the passenger.

64
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Sequence diagram of train information

railway staff form database printer

1: enter the source station

2: enter the destination station

3: enter the train no.

4: enter the train name

5: submit the details

6: process the info

7: display the train info

Collaboration diagram of train information

1: enter the source station


2: enter the destination station
3: enter the train no.
4: enter the train name
railway form
staff

7: display the train info


6: proc ess the info

5: submit the details

printer
database

65
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Activity diagram of train information

enter t he s ource
station

enter the destination


station

enter t he train
no.

enter t he train
name

incorrect info

correct info

display train
information

66
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Sequence diagram of availability of ticket

railway staff form database printer

1: enter the source st ation

2: enter the destination station

3: enter the class of coach

4: enter the date of journey

5: enter the train no.

6: enter the train name

7: submit the info

8: proces s t he info

9: display the availability

67
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Collaboration diagram of availability of ticket

1: ent er the source stat ion


2: enter the destination station
3: ent er the class of coach
4: enter the date of journey
5: enter the train no.
6: enter the train name
railway form
staff

9: display the availability


8: process the info

7: submit the info

database printer

68
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com

Activity diagram of availability of tickets

enter the source


station

enter the destination


station

enter class of
coach

enter the date of


journey

enter the train


no.

enter the train


name

reservation not available

reservation available

display available display not


available

69
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Sequence diagram of processing reservation for

railway staff form database printer

1: enter the train no.

2: enter t he train name

3: enter the source s tation

4: enter the destination station

5: enter the date of journey

6: enter the class of coach

7: enter the name

8: enter the age

9: enter the sex

10: enter the address

11: submit t he info

12: process the info

13: display the amount to be paid

70
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Collaboration diagram of processing reservation form

1: enter the train no.


2: enter the train name
3: enter the source station
4: enter t he destinat ion st ation
5: enter the date of journey
6: enter the class of coach
7: enter the name
8: enter the age
9: enter the sex
railway 10: enter the address form
staff

13: display the amount to be paid

12: process the info 11: submit the info

printer
database

71
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Sequence diagram of issuing ticket

railway staff form database printer

1: enter the passenger details

2: submit the form

3: check the passenger details

4: display invalid details

5: reenter the details

6: submit the form

7: proc ess t he info

8: print the ticket

9: update the dat abase

72
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com

Collaboration diagram of issuing ticket

1: enter the passenger details


5: reenter the details
railway form
staff

4: display invalid details


3: check the passenger details
7: process the info
9: update the database
2: submit the form
6: submit the form

8: print the ticket


database printer

73
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Activity diagram of issuing ticket

enter the train


no.

enter the
train name

enter the source


station

enter the
destination station

enter the date of


journey

enter the class


of coach

enter the no. of


passengers

enter name

enter age

enter sex

enter
address
incorrect details

print ticket

74
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com

Class diagram:

75
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Java code

import java.io.*;
class Passenger
{
String name;
int age;
String sex;
String Address;

}
class Train
{
int Train_no;
String Train_name;
}
class Form
{
Passenger pr =new Passenger();
Train tr= new Train();
String Source_Station;
String Destination_Station;
String Date_of_journey;
int No_of_pass;
String Class_of_coach;
int i;

void get_pass_details()
{
try
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("No_of_pass:");
No_of_pass=Integer.parseInt(br.readLine());
System.out.println("Name:");
pr.name=br.readLine();
System.out.println("Age:");
pr.age=Integer.parseInt(br.readLine());
System.out.println("Sex:");
pr.sex=br.readLine();
System.out.println("Address:");
pr.Address=br.readLine();
get_train_details();
}
catch(Exception e) {}
}

void get_train_details()

76
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
{
try
{
BufferedReader br=new BufferedReader(new
InputStreamReader(System.in));
System.out.println("Train Number:");
tr.Train_no=Integer.parseInt(br.readLine());
System.out.println("Train Name:");
tr.Train_name=br.readLine();
System.out.println("Source_Station:");
Source_Station=br.readLine();
System.out.println("Destination_Station:");
Destination_Station=br.readLine();
System.out.println("Date_of_journey:");
Date_of_journey=br.readLine();
System.out.println("Class_of_coach:");
Class_of_coach=br.readLine();

}
catch(Exception e) {}

class Ticket extends Form


{

Train tr = new Train();


int ticket_no;
String Source_Station;
String Destination_Station;
String Departure_Time;
int amount;
int calc_fare()
{
return 0;
}

void print_ticket()
{
ticket_no=0;
ticket_no++;
try
{
System.out.println(" ");
System.out.println("-------------------------------------------------- ");
System.out.println("Train Number : "+tr.Train_no);
System.out.println("Train Name : "+tr.Train_name);
System.out.println("Ticket Number : "+ticket_no);

77
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
System.out.print("Source Station : "+Source_Station);
System.out.print("\t To \t");
System.out.println("Destination_Station : "+Destination_Station);
System.out.println("Date_of_journey : "+Date_of_journey);
System.out.println("No_of_pass : "+No_of_pass);
System.out.println("Amount : ******");
System.out.println("---------------------------------------------------");
System.out.println(" ");
}
catch(Exception e){}

class railway
{
public static void main(String args[])
{
try
{

Ticket tk= new Ticket();


tk.get_pass_details();
tk.print_ticket();

}
catch(Exception e)
{
System.out.println("Error");
}
}
}

78
Downloaded from www.pencilji.com

Anda mungkin juga menyukai