Beruflich Dokumente
Kultur Dokumente
com
Activity Diagram:
Page 1 of 45
www.pencilji.com
Execute
program
Draw Window
Display window
Class Diagram:
WindowAdapter
JFrame (from event)
(from swing)
rootPaneCheckingEnabled : boolean WindowAdapter()
rootPane : JRootPane windowActivated()
accessibleContext : AccessibleContext windowClosed()
windowClosing()
windowDeactivated()
windowDeiconified()
windowIconified()
windowOpened()
Ruled
WindowHandler
+theWindowHandler
main()
windowClosing()
paint()
WindowHandler()
Ruled()
Code:
import javax.swing.JFrame;
import java.awt.event.*;
Page 2 of 45
www.pencilji.com
import java.awt.*;
public class Ruled extends JFrame
{
public WindowHandler theWindowHandler;
/**
@roseuid 41B93583001F
*/
public Ruled()
{
WindowHandler wh = new WindowHandler();
addWindowListener(wh);
}
/**
@roseuid 41B931CC03D8
*/
public void paint(Graphics g)
{
super.paint(g);
for(int i=0;i<400;i+=10)
{
g.drawLine(0,i,400,i);
g.drawLine(i,0,i,400);
}
}
/**
@param args[]
@roseuid 41B931E4033C
*/
public static void main(String args[])
{
Ruled r = new Ruled();
r.setSize(400,400);
r.show();
}
}
class WindowHandler extends WindowAdapter
{
/**
@roseuid 41B9358300CB
*/
public WindowHandler()
{
}
Page 3 of 45
www.pencilji.com
/**
@roseuid 41B932380222
*/
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
}
Output:
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.
Write a program to create a window and draw two sets of diagonal
parallel lines crossing each other. Device the following and then
implement.
a)High level design
b) Detail level design
c) User interface specification
Activity Diagram:
Page 4 of 45
www.pencilji.com
Execute the
program
Draw window
Draw diagonal
grid lines
Display window
Class Diagram:
WindowAdapter
(from event)
JFrame WindowAdapter()
(from swing) windowActivated()
rootPaneCheckingEnabled : boolean windowClosed()
rootPane : JRootPane windowClosing()
accessibleContext : AccessibleContext windowDeactivated()
windowDeiconified()
windowIconified()
windowOpened()
Diagonal
WindowHandler
+theWindowHandler
main()
windowClosing()
paint()
WindowHandler()
Diagonal()
Sequence Diagram:
Page 5 of 45
www.pencilji.com
objDiagonal : objWinHandler :
: User
Diagonal WindowHandler
Invoke main()
Create Window
Create WindowListener
Show Window
close window
fire close event
window terminated
Code:
import javax.swing.JFrame;
import java.awt.event.*;
import java.awt.*;
public class Crossed extends JFrame
{
public WindowHandler theWindowHandler;
/**
@roseuid 41BFE0FA0290
*/
public Crossed()
{
WindowHandler wh = new WindowHandler();
addWindowListener(wh);
}
/**
@roseuid 41BFDFB5038A
*/
public void paint(Graphics g)
{
Page 6 of 45
www.pencilji.com
super.paint(g);
for(int i=0;i<400;i+=10)
{
g.drawLine(0,i,i,0);
g.drawLine(400,i,i,400);
}
for(int j=0;j<400;j+=10)
{
g.drawLine(j,0,400,400-j);
g.drawLine(0,j,400-j,400);
}
}
/**
@param args[]
@roseuid 41BFE04201C5
*/
public static void main(String args[])
{
Crossed cr = new Crossed();
cr.setSize(400,400);
cr.show();
}
}
class WindowHandler extends WindowAdapter
{
/**
@roseuid 41BFE0FA034B
*/
public WindowHandler()
{
}
/**
@roseuid 41BFE07401C5
*/
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
}
Page 7 of 45
www.pencilji.com
a) Identify the various use cases and actors involved and represent
the user view of the system.
Page 8 of 45
www.pencilji.com
Identify the various classes and attributes and bring out a class diag.
and sequence diag.
Use case Diagram:
Through
E-Ma...
HR Head
(from Business Actors)
Communicates Communicates
Communicates HR Referral
HR_Head_OtherRe Interview process
gion (from Business UseCases)
(from Business Actors)
Interview status
Through
notice Board
Employee
Candidate
(from Business Actors)
Page 9 of 45
www.pencilji.com
Activity Diagram :
Page 10 of 45
www.pencilji.com
Initiate vacancy
Recommend
candidates
Shortlist candidates
based on skill
Conduct
interview
Select
candidates
Update acceptance/rejection
response details
Page 11 of 45
www.pencilji.com
Class Diagram:
Vacancy RefPayment
vacancyid : int empid : int
vacancytype : String bonus : int
vpriority : String empname : String
Quantity : int canName[] : String
skillset : String bonusSanctioned : Boolean
getDetails() getEmpId()
updatevacancy() sendForSanction()
showvacancy() payBonus()
SelProcess
candid : int
candname : String
candskill : String
getCanDetails()
shortlist()
processFinalList()
sendFinalCanDetails()
Sequence Diagram:
Page 12 of 45
www.pencilji.com
Maintains vacancy
shortlist candidates
send interview call letters
Interview process
send offer letters
acceptance/rejection feedback
update vacancy
send employee list for sanction of bonus
sanctioned bonus
give bonus
Page 13 of 45
www.pencilji.com
Student marks
User
Page 14 of 45
www.pencilji.com
Activity Diagram:
User executes
the program
Enter regno
Enter name
Enter marks in
subject 1, 2, 3
Compute total
Assign total = 0
Display student
details
Page 15 of 45
www.pencilji.com
Class Diagram:
Student
Regno : String
Name : String
Marks1 : int
Marks2 : int BufferedReader
Marks3 : int (from i o)
Total : int
main()
display()
Student()
Sequence Diagram:
objStudent objBReader :
: User
BufferedReader
Invoke main()
create obj
entered details
set details
check if pass
compute total
show details
Page 16 of 45
www.pencilji.com
import java.io.*;
public class Student
{
private String regno;
private String name;
private int sub1;
private int sub2;
private int sub3;
private int total;
total=0;
System.out.print("\n\t\t\tEnter Student Details");
System.out.print("\n\t\t\t---------------------");
Page 17 of 45
www.pencilji.com
Name: ray
Subject1 Marks: 99
Subject2 Marks: 98
Subject3 Marks: 97
Name: george
Subject1 Marks: 99
Subject2 Marks: 35
Subject3 Marks: 98
Page 18 of 45
www.pencilji.com
Page 19 of 45
www.pencilji.com
Execute
Program
Enter Subject
Details
Enter Student
Details
Process
Student Marks
Display Student
Report
Activity Diagram
Class Diagram:
Page 20 of 45
www.pencilji.com
Students
regno : String Subject
Name : String subcode : String
Total : int +theSubject subtitle : String
marks[] : Int minmarks : int
maxmarks : int
display()
Students() Subject()
main()
+theBufferedReader
+theBufferedReader
BufferedReader
(from i o)
Sequence Diagram:
objStudents : objSubject :
: user
Students Subject
invoke main()
process marks
display student report
import java.io.*;
public class Students
Page 21 of 45
www.pencilji.com
{
private String regno;
private String name;
private int marks[];
private int total;
public static Subject theSubject[];
/**
@roseuid 41B7FDED01D4
*/
public Students() throws IOException
{
marks=new int[6];
total=0;
boolean flag=false;
BufferedReader br=new BufferedReader(new
InputStreamReader(System.in));
System.out.print("\n\t\t\tStudent Details");
System.out.print("\n\t\t\tReg No.: ");
regno=br.readLine();
System.out.print("\n\t\t\tName: ");
name=br.readLine();
for(int i=0;i<6;i++)
{
System.out.print("\n\t\t\tSubject " + (i+1) + " Marks: ");
marks[i]=Integer.parseInt(br.readLine());
if(marks[i] < theSubject[i].min)
flag=true;
}
for(int j=0;j<6;j++)
{
if(flag)
{
total=0;
break;
}
else
total=total + marks[j];
}
}
/**
@roseuid 41B7FDF90399
*/
Page 22 of 45
www.pencilji.com
Page 23 of 45
www.pencilji.com
/**
@roseuid 41B808DF01C5
*/
public Subject()
{
}
/**
@return java.lang.Void
@roseuid 41B7FFD102FD
*/
public Void setSubDetails() throws IOException
{
BufferedReader br=new BufferedReader(new
InputStreamReader(System.in));
System.out.print("\n\t\t\tEnter Subject Details");
System.out.print("\n\t\t\tSubject Code: ");
subcode=br.readLine();
System.out.print("\n\t\t\tTitle: ");
title=br.readLine();
System.out.print("\n\t\t\tMin Marks: ");
min=Integer.parseInt(br.readLine());
System.out.print("\n\t\t\tMax Marks: ");
max=Integer.parseInt(br.readLine());
return null;
}
}
Page 24 of 45
www.pencilji.com
Title: DO
Min Marks: 45
Max Marks: 100
Enter Subject Details
Subject Code: MCA55
Title: DOS
Min Marks: 45
Max Marks: 100
Enter Subject Details
Subject Code: MCA56
Title: lab
Min Marks: 45
Max Marks: 100
Enter Subject Details
Subject Code: MCA56
Title: lab
Min Marks: 45
Max Marks: 100
Student Details
Reg No.: 1
Name: ray
Subject 1 Marks: 99
Subject 2 Marks: 98
Subject 3 Marks: 97
Subject 4 Marks: 99
Subject 5 Marks: 95
Subject 6 Marks: 99
Student Details
Reg No.: 2
Name: george
Subject 1 Marks: 99
Subject 2 Marks: 97
Subject 3 Marks: 25
Subject 4 Marks: 99
Subject 5 Marks: 88
Subject 6 Marks: 89
Page 25 of 45
www.pencilji.com
a) Make
b) Screen size
c) Purchase data
d) Color/ b-w
Define a class television. Define a method for displaying the attribute
values of T.V. represent this problem specification using UML class
notations and write a java program for the same. The television class
should be defined with the required attributes. The main method
should be written to test methods of television class. For e.g. Display
TV () 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 system.
b) Identify the various classes and attributes and bring out a class
diagram, and a sequence diagram.
TV attributes
user
Activity Diagram:
Execute
Program
Accept TV
attributes
Dispaly TV
attributes
Exit Program
Class Diagram:
Page 26 of 45
www.pencilji.com
Television
make : String
screen : int
purdate : Date BufferedReader
+theBufferedReader
blkcolor : String (from io)
Television()
display()
main()
Sequence Diagram:
objTV: objBr:
: user
Television BufferedReader
initiate main()
create buffer
enter TV attributes
set TV attributes
display TV attributes
exit program
import java.io.*;
Page 27 of 45
www.pencilji.com
import java.util.*;
import java.lang.*;
public class Television
{
private String make;
private int size;
private Date purdt;
private boolean color;
public Television() throws IOException
{
BufferedReader br= new BufferedReader(new
InputStreamReader(System.in));
int opt;
System.out.print("\n\t\t\tTelevision Details");
System.out.print("\n\t\t\tMake: ");
make=br.readLine();
System.out.print("\n\t\t\tSize: ");
size=Integer.parseInt(br.readLine());
purdt=new Date();
System.out.print("\n\t\t\tSelect: ");
System.out.print("\n\t\t\t1. Colored");
System.out.print("\n\t\t\t2. Black & White");
System.out.print("\n\t\t\tYour Option: ");
opt=Integer.parseInt(br.readLine());
if(opt==1)
color=true;
else
color=false;
}
public Void display()
{
System.out.print("\n\t\t\tTelevision Details");
System.out.print("\n\t\t\tMake: " + make);
System.out.print("\n\t\t\tSize: " + size);
System.out.print("\n\tPurchase Date: " + purdt);
System.out.print("\n\t\t\tType: " );
if(color)
System.out.print("Colored");
else
System.out.print("Black & White");
return null;
}
public static void main(String args[]) throws IOException
{
Page 28 of 45
www.pencilji.com
Page 29 of 45
www.pencilji.com
Activity Diagram:
Execute the
program
input principle
input rate
input time
compute simple
interest
compute amount
Class Diagram:
Page 30 of 45
www.pencilji.com
Si
p : double
r : double
t : int
+theBufferedReader
BufferedReader
si : double
amt : double
main()
compute()
Si()
Code:
import java.io.*;
public class Si
{
private double p;
private double r;
private int t;
private double si;
private double amt;
public BufferedReader br;
/**
@roseuid 41C7E59202FD
*/
public Si() throws IOException
{
br = new BufferedReader(new InputStreamReader(System.in));
System.out.print("\n\t\t\tPrinciple: ");
p=Double.valueOf(br.readLine()).doubleValue();
System.out.print("\n\t\t\tRate of Interest: ");
r=Double.valueOf(br.readLine()).doubleValue();
System.out.print("\n\t\t\tNo. of Years: ");
t=Integer.parseInt(br.readLine());
}
/**
@param args[]
@roseuid 41C7E392001E
*/
public static void main(String args[]) throws IOException
{
Si s = new Si();
s.compute();
Page 31 of 45
www.pencilji.com
/**
@roseuid 41C7E3980138
*/
public void compute()
{
si=(p*r*t)/(double)100;
amt=p+si;
Principle: 5000
Rate of Interest: 5
No. of Years: 5
Amount: 6250.0
Page 32 of 45
www.pencilji.com
CUSTOMER
ACCOUNT
DEPOSIT
Class Diagram:
Customer
Address
custid : int
street : String
fname : String
city : String
lname : String
+theAddressstate : String
dob : Date
country : String
address : Address
pincode : String
phoneno : String
Address()
Customer() +theCustomer
display()
display()
Account
Deposit users : int
principle : int accno : long
rate : double
+theDeposit cust[] : Customer
years : int deposit : Deposit
Deposit() main()
display() Account()
displayAccountdetails()
Page 33 of 45
www.pencilji.com
Consider the object COLLEGE of mini project. For the entire given
specifications in the problem construct the following UML diagrams.
Specifications:
In a college of computer science there are comp lab and equipments.
Develop a system to create the college as an object and display the
contents.
1. class diagram
2. object diagram
3. interaction diagrams
sequence
collaboration
4. deployment diagram
Class Diagram:
Staff
College
name : String
principal : String
staffId : int
name : String
stafftype : String
address : String
dateofjoining : Date
totalintake : int
qualification : String
College()
Staff()
displayContents()
display()
Network
Laboratory type : String
noofcomputers : int platform : String
noofnetworks : int size : int
speed : int
Laboratory()
display() Network()
display()
Computer
compid : String
type : String Printer
processor : String printerid : String
opsys : String type : String
softwares : String make : String
Computer() Printer()
display() display()
Page 34 of 45
www.pencilji.com
Sequence Diagram:
Page 35 of 45
www.pencilji.com
Collaboration Diagram:
1: assigns laboratory
7: display staff details
objColle objStaff :
ge 8: display lab details Staff
3: establishes network(s)
9: display network details
objNet :
Network
11: display printer information
5: uses
4: establishes communication
objComp:
10:: display computer details objPrint: :
Computer Printer
Deployment Diagram:
College
Network
Comput
er
Page 36 of 45
www.pencilji.com
Book lending
member
Maintaining titles
Librarian Supplier
Page 37 of 45
www.pencilji.com
User logs in to
the system
borrow book
Update Book
Catalog view catalog Ask for
registeration
Page 38 of 45
www.pencilji.com
purchase titles
receive order
update catalog
no reservations
Page 39 of 45
www.pencilji.com
update catalog
notify librarian
update the catalog
Page 40 of 45
www.pencilji.com
objReserve :
Reserve
: member
3: get sanction
: Librarian
Page 41 of 45
www.pencilji.com
verify catalog
place order for titles
send notification
brings titles
notify librarian
update catalog
notify member of arrival of reserved title
4: brings titles
: Supplier
3: send notification
objPur: :
Purchase
5: notify librarian
: Librarian
Page 42 of 45
www.pencilji.com
Class Diagram:
Purchase
(from m ai ntenance)
purid : int
Borrow
orderdate : Date
refno : int purchasedate : Date
dateofborrow : Date Remove
refno : int (from m aintenance)
returndate : Date userid : int
userid : int refno : int
removetitle : String
Purchase()
Borrow() updateCatalog()
showdetails() Remove()
notifysupplier()
asksanction() updateCatalog()
notifyLibrarian()
updateCatalog() displayRemoveList()
Catalog
User title : String
userid : int isbn : String
usertype : String price : int
username : String publisher : String
useraddress : String author : String
refno : int
User() type : String
display()
Catalog()
showtitledetails()
updatedetails()
notify()
Return Reserve
refno : int refno : int
userid : int userid : int
dateofreturn : Date dateofreserve : Date
fine : int availability : Boolean
Return() Reserve()
computeFine() verifyCatalog()
updateCatalog() displayReserveList()
notifylibrarian()
Page 43 of 45
www.pencilji.com
Component Diagram:
UI Borrow
Return
Maintain Purchase
Catalog Remove
Deployment Diagram:
Librarian's
Desk Supplier
Recepti
on
Page 44 of 45
www.pencilji.com
Page 45 of 45