Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
com
P R O GR A M 2: GR ID L IN ES
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
}
1
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
P R O GR A M 3: GR ID W IT H T W O S E TS O F D I A G O N A L L IN ES
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
PRO B LEM 4
Proble m de finition
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.
R E Q UIR E M EN TS SP E C I FI C A TI O N
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
Acto rs:
Actors are as follows:
1. H R He ad.
2. E mployee.
3. Candidates.
2. E mployee :
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 D iagra m:
Notify Vacancy
Fill referral Form
<<Uses>>
HR Head
Selection of Eligible
Candidates
<<Extends>> Employee
Interview Process
A ward Bonus
5
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
USE C AS ES:
6
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Use Case : Intima tion to the se lecte d candida tes.
D escription: 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 Eve nts 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 rna te 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 Vaca ncy :
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
Selection of Candidates:
Online Interview IS
: HR Head System : Candidate
1: Initiate Interview
3: Receives reply
8
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Email
: HR Head System : Candidate : Employee
4: Recieves Acceptance
Emai l : Candidate
: HR Head System
9
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
C L ASS D I A G R A M
10
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
H R He ad:
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.
M ainte na nce :
The Maintenance class is responsible for maintaining the Information System(IS)
where the information about the candidates and the employees are stored.
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.
Se lecte d Candidates:
This class contains the details of the selected candidates after the Interview
process.
11
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
P R O GR A M 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.
D escription
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.
R e qui re me nt 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
Fac ulty: It refers to the person who enters the marks and calculates the result.
Stude nt : The student uses the system to view their result.
marks processing
<<extends>>
student faculty
result processing
display result
M arks processing
1. D escription: Initiated by the faculty to enter the marks.
2. Precondition: -
3. Normal F low of Eve nt:
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 rna te flow of e ve nt: -
5. Post condition: -
13
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
R esult Processing
D isplay result
14
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Sequence diagrams
1. Se que nce diag ra m fo r ma rks processing:-
faculty database
Information
Syste...
3: Save in database
5: Enter marks
6: Save marks
faculty database
Information
syste...
4: retrieve marks
15
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
3. Se que nce diag ra m fo r display ing result:
student database
information
syste...
3: retrieve result
4: Send result
5: Display result
C ass diagram
C lass Documentation
Stude nt :
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
P R O GR A M 6
Proble m de finition:
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.
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 system must be interactive and suitable user authentication mechanism must
be incorporated.
19
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Acto r Doc ume nta tion
Acto rs:
Faculty: provides the marks of each student for processing the results.
Usecase D iagra m:
LOGIN
FACULTY
<<USES>>
Usecase documentation:
1 Usecase na me : 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 O f Eve nts:
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 rna te 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.
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 O f Eve nts:
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 rna te Flow 1: Display Error Message. Request another register number.
Postcondition: Based on the constraints specified and marks, results of each
student are provided.
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 Eve nts:
1. Request entry of marks.
2. Enter marks.
3. Verify whether entered marks are valid,
If valid continue otherwise Alternate flow 3.
Alte rna te flow 3: Display error message, re-enter marks.
Postcondition: Enter marks are verified and are stored to perform processing.
21
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Sequence Diagrams:
Se que nce diag ra m fo r M arks e nt ry a nd M arks Processing
Faculty Database
System :
NewInterface
1: Requrest Regester Number
3: Verify
4: Found Valid
6: Enter Marks
7: Verify Entered Marks
9: Transaction Successful
11: Terminate
22
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Se que nce diag ra m fo r Login
User System
3: Not valid
4: Request re-entry
6: Vali d user
7: Perform operations
Student Database
System :
NewInterface
1: Request Register Number
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 D iagra m
24
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Prog ra m
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
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
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
P roblem: 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.
R e qui re me nts
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.
4. The system should be able to display the price list based on the customer
Specification.
Acto rs
Ope rato r:
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
JAV A C OD E
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
D escription: 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 e ve nts : 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.
D escription: 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 e ve nts : 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 rna tive F low : 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.
D escription: 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 e ve nts : 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 D iagra m
Display TV Models
<<uses >>
Operator
Aut hent icat ion
Classes
Te le vision Class:
32
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
T ra nsaction ma nage r:
O O 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.
Acces s Granted
33
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Di spl ay Model
Di spl ay Priceli st
34
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
P rogram 8
B ank I nte rest Computation
R e qui re me nt Specification:
Customer deposits money in the bank. The deposited money is called the
Princ iple A mount.
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
Acto rs:
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 C AS E :
Verify Account
D eposi t Administrator
Account
Holder
Calculate Interest
DBMS
Display
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
F low of events:
Ve rify Account :
Pre-condition:
The Account Holder should have a PIN number.
Normal F low:
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 rna te Flow 1:
Requested pin number again.
Alte rna te 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.
D e posit M one y:
Pre-Condition:
The account is validated.
Normal F low:
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 rna te Flow:
1. Balance remains unchanged.
Post-Condition:
The amount is deposited to the respective account type and balance is updated.
Pre-Condition:
The minimum balance should be there.
Normal F low:
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
A mount = 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 rna te Flow:
1. Display “ No minimum balance”
Post-Condition:
The Simple Interest is calculated and balance is updated.
D isplay O utput :
Normal F low:
1. The updated current balance is displayed on the screen by the
DBMS to the user.
Alte rna te Flow:
No Alternate Flow.
Post-Condition:
The Transaction is successful and completed.
C L ASS D I A G R A M
38
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Account Holde r - 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.
Administra to r - 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.
D e posit - 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));
void ShowDetails()
{
System.out.println(" Account Holder Name : " + name);
System.out.println(" Account Number : " + accno);
System.out.println(" Account Balance : " + balance);
}
}
40
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
void CalculateInterest()
{
try
{
BufferedReader BR = new BufferedReader( new
InputStreamReader(System.in));
void ShowAmount()
{
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. O O A A N D O O D USIN G R A U M B H A G A N D U M L V I
In a bank the customer opens an account and in that account he/she deposits
money. So the entities are:
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.
T ES T C AS E :
Address
D e posit:
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 use rs:
Deposit:
Principle:
Rate of interest:
No of years:
Simple interest:
Amount:
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.
R e qui re me nts:
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
ID EN TI FI C A TI O N O F A C T O RS:
Acto rs:
1) Clerk
2) BIS
A C T O R D O C U M EN T A TI O N :
Cle rk :
This actor is responsible for processing the client request, authentication and
carrying out the transactions of the client.
B IS:
This actor is responsible for holding the details of various transaction of the client.
USE C AS E D I A G R A M :
Interest Calculation
Clerk BIS
Deposit Money
USE C AS E D O C U M EN T A TI O N :
(1)
USE C AS E N A M E : D EP OSI T M O N E Y
44
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
N OR M AL FL O W 1.Enter account number
2.Valid account number
3.Enter customer id.
4.Valid customer id.
5.Enter amount for deposit (cash).
A L T ER N A TI V E F L O W Not authenticated.
POS T C O N D I TI O N Update of transaction.
(2)
USE C AS E N A M E : IN T ER EST C A L C U L A TI O N
D ESC R IP TI O N This use case is initiated by bank clerk. It
calculates the simple interest and updates the
balance amount.
PR E- C O N D I T I O N Verification and validation of account number,
user id authenticated by clerk through BIS.
N OR M AL FL O W Calculation of simple interest.
A L T ER N A TI V E F L O W Not authenticated.
POS T C O N D I TI O N Update Balance.
C L ASS D I A G R A M :
45
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
D esign Phase :
46
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
P roblem 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
R e qui re me nts:
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.
Acto rs:
1. Lab User
2. Maintenance Person
3. Database
1. Lab User: User is an actor who views the details of the laboratory
equipments.
47
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Authentication
Database
Maintenance
person <<uses>>
Update
Authe nticate : 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 e ve nts:
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 rna te 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
Upda te : This Use case is initiated by the maintenance person. The maintenance person is
allowed to update the database.
Flow of e ve nts:
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 de tails : This Use case is initiated by general user. User is allowed to view the
details of the lab.
Flow of e ve nts:
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:
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. Se que nce diag ra m fo r U pdate :
Maintenance Database
person
: maintenanceForm
1: Enter id & password
2: Verify
3: verification
4: Valid User
5: Request details
6: Enter details
7: Update 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. Colla bo ra tion diag ra m fo r A uthe ntication:
1: Request details
User
5: Display details
: viewdetailsForm
4: Send details
3: Retrieve
2: Check database
Database
3: verification
Database
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 diag ra m:
Softwa re Class: The attributes here are license, No of copies and validity.
La b C lass: The attributes here are Lab- id, which is meant for identification of labs.
Pe riphe ra ls Class: The attributes here are Make and Type.
E quipme nt C lass: The attributes here are Equipment-Id, Purchase-date and Warranty.
D e ployme nt diag ra m:
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
P rogram11:
C L ibra ry I nfo rmation Syste m
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.
R e qui re me nt Specification
1) Notify: The librarian initiates this use case when any member returns the book
and checking if the book is already reserved.
2) Bor row Book : Initiated by librarian when any member wants to borrow the
desired book. If the book is available, the book is issued.
53
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
3) R ese rve 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.
4) R e turn Books: Invoked by the librarian when a member returns the book.
5) Check libra ry ca rd: The borrow and return use-cases use it to check the validity
of the user-card.
6) Add Books: The purchase book use-case when new books invoke it or magazines
are added to the library.
7) R e move Book : Initiated by the Library Inventory Manager when old and
damaged books are removed from the library.
54
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Notify
<<Uses>>
<<Uses>>
Return Book
2) Libra ry I nve nto ry M anage r: 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
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
2: Get File
3: Valid User
4: Get book_id
5: Update
6: Issue Book
Librarian
3: Valid User
6: Issue Book
Lib Info
System
57
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
2: Get File
3: Valid User
4: Get book_id
6: Display Unavailable
8: 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
2: Get File
3: Valid User
4: Enter book_id
8: Notify if reserve
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
Activ ity diag ra m fo r libra ry
Verify Id
Class D iagra m
60
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
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
3) M agazines: 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) T ra nsaction: Its main class contains the inheritance relationship with Borrow and
Return book.
5) Bor row Book : Contains details about the borrow book that is which member
Borrow particular book and its return date.
Compone nt D iag ra m
Transaction Member
Catalogue
61
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
P rogram-12:
Develop the product using java programming language. Write UML
diagram for Railway Reservation System.
<<uses>>
Railway
Reservation staff
Database
Train Information
<<extends>>
issuing of tickets
62
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Acto rs:
R ailway R ese rvation Staff
D atabase
D escription of Acto rs:
D atabase:
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.
63
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Alte rna tive F low 1: Display the details to re-enter the missed details.
Post-condition: The customer will be issued the ticket.
4. Issuing ticke t:
64
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Se que nce diag ra m of t rain info rmation
printer
database
65
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Activ ity diag ra m of t rain info rma tion
enter t he s ource
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
Se que nce diag ra m of ava ila bility of ticke t
8: proces s t he info
67
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Colla bo ra tion diag ra m of ava ila bility of ticke t
database printer
68
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
enter class of
coach
reservation available
69
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Se que nce diag ra m of processing rese rvation fo r
70
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Colla bo ra tion diag ra m of processing rese rvation fo rm
printer
database
71
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Se que nce diag ra m of issuing ticke t
72
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
73
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Activ ity diag ra m of issuing ticke t
enter the
train name
enter the
destination station
enter name
enter age
enter sex
enter
address
incorrect details
print ticket
74
Downloaded from www.pencilji.com
Downloaded from www.pencilji.com
Class diag ra m:
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) {}
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
{
}
catch(Exception e)
{
System.out.println("Error");
}
}
}
78
Downloaded from www.pencilji.com