You are on page 1of 70

OOPS THROUGH UML LAB MANUAL

ACADEMIC YEAR 200 —200

DEPARTMENT OF
COMPUTER SCIENCE AND
ENGINEERING
PREFACE

UML is a language used for visualizing, specifying, constructing, and


documenting the artifacts of a software intensive system.

This manual is designed and developed under the syllabus pattern


introduced by Jawaharlal Nehru Technological University for the V
semester B.Tech Computer Science and Engineering department for the
Language Processor Lab. This manual is indented for an introductory
course in OOPS through UML at the graduate level students. It provides to
a way to represent the artifacts of a software intensive system in a
standardized manner.

The primary purpose of this manual is creating a comprehensive


understanding of the OOPS concepts with their application in UML along
with mapping it to various programming languages.

We are liable to convey our sincere thanks to our H.O.D. and all the
staff members of CSE for their helping hands to produce this successful
manual.

STAFF INCHARGE HOD/CSE PRINCIPAL


OOPS LAB THROUGH UML

TABLE OF CONTENTS

S.NO TITLE PAGE NO

5
1. Introduction

List of programs:

11
2. Airlines Reservation System
27
3. ATM Model
37
4. Auction Application
39
5. Course Registration
43
6. Online Book Shop
54
7. Personal Computer Model
55
8. Plant Model
56
9. Point Of Sale
31
10. Simulated Company
58
11. Student Model
67
12. Telephone Dialing
68
OOPS LAB THROUGH UML

CALENDER

S.NO TITLE DATE REMARKS

1. Airlines Reservation System


2. ATM Model
3. Auction Application
4. Course Registration
5. Online Book Shop
6. Personal Computer Model
7. Plant Model
8. Point Of Sale
9. Simulated Company
10. Student Model
11. Telephone Dialing
INTRODUCTION TO UML

UML is a language used for visualizing, specifying, constructing and


documenting the artifacts of a software intensive system.

Building Blocks of UML :

 Things
 Relationships
 Diagrams

Things in UML :
 Structural things
i. Classes
ii. Interfaces
iii. Collaborations
iv. Use Cases
v. Active Classes
vi. Components
vii. Nodes Classes

 Behavioral things
i. Interactions
ii. State machines

 Grouping things
i. Packages

 Annotational things
i. Notes
Relationships in UML :
 Dependency
 Association
 Generalization

Diagrams in UML :
 Class Diagram
 Object Diagram
 Usecase Diagram
 Sequence Diagram
 Collaboration Diagram
 Statechart Diagram
 Activity Diagram
 Component Diagram
 Deployement Diagram

Class :

MyFrame
height : int = 300
width : int = 400
status : int = 1
title : String = "Demo Frame"

MyFrame() : MyFrame
open(void) : void
close(int status) : void
resize(int height, int width) : void
minimize(void) : void
maximize(void) : void

Interface :

<<Interface>>
MouseListener
(from event)

mouseClicked()
mousePressed()
mouseReleased()
mouseEntered()
mouseExited()

Collaboration :
Use Case :

Place Order

Active Classes :

Active Classes :

OrderForm.java
Node :

File Server

Interaction :

State Machine :
Packages :

Grouping things are the organizational parts of UML


models. These are the boxes into which a model can be
decomposed. In all, there is one primary kind of grouping
thing, namely, Packages.

java.swing.*

Notes :

Annotational things are the explanatory parts of


UML Models. These are the comments you may apply to
describe and illuminate about any element in a model.

return copy of self
Dependency :

Association :

Generalization :

Realization :
LAB EXERCISES

1. Airlines Reservation System


Add sequence diagram :-

administrator addform addcontroller errormessage passenger DB

requestfieldvalues()

enter_field_values()

validate()

invalid()

Display_error_messages()

valid_add_record()

Delete sequence diagram :-


administrator deleteform deletecontroller errormessages passengerDB

request_key_field()

enter_key_field()

validate()

invalid()

display_error_messages()

valid_delete_record()

Fight Database Maintanance :-


administrator domainform domaincontroller

request_operator()

specify_operation()

add()

sequence 
diagram

delete()

sequence
diagram

update()

sequence
diagram

Update sequence diagram :-


Mo

administrator updateform updatecontroller errormessages flight DB

request_key_field()

enter_key_field()

validate()

lookup()

query_result()

no_such_record()

recordexist_displayrecord()

edit_details()

validate()

invalid()

valid_update_record()

Mode of payement sequence diagram :-


reserver reservation form reservation  banking details banking DB error messages printer
controller

request_mode_of_payment()

select_mode_of_payment()

select_mode()

if_credit_cord()

request_banking_details()

enter_bank_details()

lookup()

query_result()

invalid()

if_valid()

diveconfirmation()

if_cash()

deliver_ticket()

Add collaboration diagram :


2: enter_field_values() 3: validate()
administrator addform addcontroller

1: request_field_values()

5: displat_error_messages()
4: invalid()

6: valid_add_record()

passenger DB
errormessages

Delete collaboration diagram :-


2: enter_key_field() 3: validate()
8: edit_details() 9: validate()

administrator updateform updatecontroller

1: request_key_field() 7: recordexist_displayrecord()

4: lookup()
11: valid_update_record()
5: query_result()
6: no_such_record()
flight DB
errormessages 10: invalid()

Update collaboration diagram:-


2: enter_key_field() 3: valid()
8: edit_details() 9: validate()

administrator updateform updatecontroller

1: request_key_field() 7: recordexit_displayrecord()

4: lookup()
11: valid_update_record()
5: query_result()

6: no_such_record()
10: invalid()
errormessages passengers DB

Add(flight) Sequence diagram :-


administrator addform addcontroller errormessage flight DB

request_field_values()

enter_field_values()

validate()

invalid()

display_error_messages()

valid_add_record()

Update(flight) collaboration diagram:-


2: enter_key_field() 3: validate()
8: edit_details() 9: validate()

administrator updateform updatecontroller

1: request_key_field() 7: recordexist_displayrecord()

4: lookup()
11: valid_update_record()
5: query_result()
6: no_such_record()
flight DB
errormessages 10: invalid()

Booking collaboration diagram :-


3: enter_details()
9: select_flight()
13: enter_passenger_details()

reserver welcomeform reservationform

1: welcome_reservor() 2: request_details()
12: request_passenger_details()
15: mode_of_payment()
16: store_passenger_details()
8: display_flight_details()
4: passplaces()
10: selected_flight()
14: process_passenger_details() passenger DB
reservationcontroller
5: lookup()
11: look_selected_flight_record() 17: update_flight DB
18: unlock_the_record()

6: query_result()
flight DB
7: no_match_found()
errormessages

Login sequence diagram :-


administration loginform logincontroller welcomeform errormessages

request_details()

enter_details()

password_details()

valid()

invalid()

display_error_messages()

Maintain passenger Database sequence diagram :-


administrator domainform domaincontroller

enter_the_operation()

add()

sequence
diagram

delete()

sequence
diagram

update()

sequence
diagram

Maintain passenger database :-


administrator domainform domaincontroller

enter_the_operation()

add()

sequence
diagram

delete()

sequence
diagram

update()

sequence
diagram

Update passenger database sequence diagram :-


administrator updateform updatecontroller errormessage passenger DB

request_key_field()

enter_key_field()

validate()

lookup()

query_result()

no_such_record()

recordexist_displayrecord()

edit_details()

validate()

invalid()

valid_update_record()

Delete flight database sequence diagram:-


administration loginform logincontroller welcomeform errormessages

request_details()

enter_details()

password_details()

valid()

invalid()

display_error_messages()

Booking sequence diagram:-


reserver welcomeform reservationform reservation errormessages passenger DB flight DB
controller

welcome_reservor()

request_details()

enter_details()

passplaces()

lookup()

query_result()

no_match_found()

display_flight_details()

sellect_flight()

sellected_flight()

lock_sellected_flight_reserve()

request_paddenger_details()

enter_passenger_details()

process_passenger_details()

mode_of_payment()

sequence
diagram store_passenger_details()

update_flight  DB

unlock_the_reader()
Login collaboration diagram :-
2: enter_details() 3: passdetails()
administrator loginform logincontroller

1: request_details()

5: invalid()

4: valid() 6: diaplay_error_messages

welcomeform errormessages

Maintain passenger database collaboration diagram :-


2: enter_details() 3: passdetails()
administrator loginform
logincontroller

1: request_details()

5: invalid()

6: display_error_messages()
4: valid()
errormessages
welcomeform

Maintain flight database collaboration diagram :-


2: specify_operation()
administrator domainform

1: request_operation()

3: add()
4: delete()
5: update

domaincontroller

Delete flight DB collaboration diagram :-


2: enter_key_fields() 3: validate()
administrator deleteform deletecontroller

1: request_key_fields()

5: displsy_error_messages() 6: valid_delete_record()
4: invalid() flight DB
errormessages

Mode of payment collaboration diagram :-

11: diveconformation()

reservor 10: ifvalid() reservationcontroller


2: selected_mode_payment()
4: 
3: selected_mode()

1: request_payment_details()
12: ifcash()
9: invalid_data()
reservationform
13: deliver_ticket()
5: request_bank_details()

printer
6: enter_bank_details()

8: quert_result()

7: lookup()
bankingdetails banking DB errormessages
2. ATM MODEL :
Login sequence diagram:-

user login form login controller welcome display error database


message message

1: user login()

2: request username & pswd()

3: enter username & pswd()

4: reffering the details of the users

5: validation of username & pswd

6: valid username & pswd

7: invalid username & pswd

8: display error message

Creating cards sequence diagram:-


manager user main form application form controller display error
message

1: enquiring details

2: providing details to user

3: requesting application form

4: providing application form

5: submission of application form for validation

6: valid application form

7: invalid application form

8: display error message

9: user refills the application form again

Creating codes sequence diagram:-


manager administrator verification assigning database
codes

1: providing card information

2: verification

3: valid

4: updation of database

5: invalid

Selecting modes:-

users main form controller

1: display options of deposit & withdraw

2: select options

3: deposit option is selected

Sequence
diagram

4: withdraw option is selected

Sequence
diagram
Deposit sequence diagram :-

user controller ATM

1: user is used for amount

2: enter the amount

3: user is provided with various modes of payments

4: select modes of payments

5: selecting cash()

sequence
diagram

6: selecting cheque()

sequence
diagram

Deposit cash sequence diagram:-


user controller ATM database

1: insert cheque for verification

2: provides acknowledgement

3: cheque is provided to system

4: updating database

Withdraw sequence diagram :-


user controller ATM

1: user is asked for amount

2: enter amount

3: user is provided with various modes of payment

4: select mode of payment

5: selecting cash

Sequence
diagram

6: selecting cheque

Sequence
diagram

Withdraw cash sequence diagram:-


user ATM database

1: cash is provided from system

2: updating database

Login collaboration diagram:-


1: user login 3: enter username & pswd 5: validation of username & pswd
login login
user
form controller

2: request username & pswd

4: reffering details of the user

6: valid usrname & pswd


7: invalid username & pswd

databas
welcome display error e
message mesage

8: display error message

Creating cards collaboration diagram:-

manager main
form
1: enquiring details

2: providing details
user

6: valid application form

5: sub mission of application form for validation

3: requesting application form


9: user refills the application form

8: display error message


controlle
4: providing application form r 7: invalid application form

applicatio display error


n form message

Creating codes collaboration diagram:-


5: invalid
verificati
manager
on

1: providing card information

2: verification

3: valid
administ
rator
assigning
codes

4: updating database

databas
e

Selecting method collaboration diagram:-


2: enter the amount 4: select mode of payment
controlle
user
r

3: user is provided with various modes of payment 1: user is asked for amount

5: selecting cash

6: selecting cheque

ATM

Deposit collaboration diagram:-


2: select options
main
user
form

1: display options for deposit & withdraw

3: deposit option is selected

4: withdraw option is selected

controlle
r

Deposit cheque collaboration diagram:-


1: insert cheque for verification
controlle
user
r

2: provides acknowledgement

3: cheque is provided to system

4: updating database
databas
ATM
e

Withdraw collaboration:-
2: enter the amount 4: select mode of payment
controlle
user
r

3: user is provided with various modes of payment 1: user is asked for amount

5: selecting cash

6: selecting cheque

ATM

Withdraw cash collaboration diagram:-


user

1: cash is provided from the system

2: updating database
databas
ATM
e
3. Auction Application :
Purchasers sequence diagram:-

purchaser auction mail goodsroom negotiation  chatting database


room

login

verify user

display goods

select goods

short the store of auction

enter chatting

bidding

select method of bidding

record contents

end of negotiation

broadcasting result

Collaboration diagram:-
negotiation 
6: enter chatting room

goodsroom
purchaser
1: login
2: verify user

3: displaygoods
4: selectgoods
7: bidding
8: select method of bidding auction 
mail

5: short the store of auction
9: record content od charting
chatting database
4. Course Registration :
Login sequence diagram:-

User MainWindow LoginWindow LoginControl Welcome ErrorMessage


Window
1: Logging In

2: Ask for user ID and Password

3: Verify user ID and password

4: Valid user

5: Invalid User

6: Error Message

7: Relogin / Cancel

Registration sequence diagram:-


Student Registration Form Control Error Message Database
Form
1: Registration Form

2: Request Details

3: Enter Details

4: Validation

5: Verify Elective Details

6: Store Details

7: Confirm Message

8: Invalid Elective

9: Display Reason

10: Invalidate

11: Re-register

Course details sequence diagram:-


Student CourseForm CourseForm ErrorMessage Database
Control

1: Select Course

2: Validate Course

3: Get Course Information

4: Display Course Information

5: Invalid Course

6: Display Error Message

Login collaboration diagram:-


1: Logging
User Login
Window
2: Ask For ID
7: reLogin / Cancel
Main
Window

6: Error Message
3: Verification
Login 5: Invalid Error
Control Message

4: Valid Welcome
Window

Registration collaboration diagram:-


1: Registration Form
3: Enter Details
11: re-registration
Student Registration
Form
5: Verify Elective Details 2: Request Details

7: Confirm Message
4: Validation
10: Invalid
Form
Control
9: Display

6: Store Details
8: Invalid Choice
Error Databas
Message e

Course details collaboration diagram:-


5: Display Course Information
Student CourseForm
Control
1: SelectCourse
2: Validation

Course
Form

7: Display Error Message 3: Get Course Infomation 4: Get Course Information

6: Invalid
Error
Message Databas
e
5. Online Bookshop :
Login sequence diagram:-

user mainform loginform welcomeform logincontroller errorcontroller database

1:login()

2:enter username/password

3:authenticatio

4:enter into database

5:valid

6:invalid

7:error message

8:relogin

View reports sequence diagram:-


administrator mainform controller errormessages database

1:request id

2:enter id

3:verification

4:invalid

5:errormesage

6:re_enterid

7:verified

8:generate reports

View stock sequence diagram:-


cuatomer mainform controller errormessages database
administrator

1:request book details

2:verify

3:not filled property

4:error message

5:verified

6:retrieve data

Maintain book stock sequence diagram :-


manager option form book profile 
form

1:to avial option

2:add books

sequence
diagram

3:update books

sequence
diagram

4:delete books

sequence
diagrams

Add books sequence diagram :-


manager new book add  book controller error message database
form

1: request for new book

2:add new book

3:verification

4:not filled properly

5:error message

6:filled property

7:generate id

Modify books sequence diagram :-


manager selector form modification  modification  errormessage database
form controller

1:request to select book

2:selecting book

3:intimate database

4:retrive data

5:modify

6:verification

7:improper

8:error message

Delete books sequence diagram :-


manager selector form deletion form database

1:select book

2:retriving data

3:deleting

4:update()

Login collaboration diagram:-


1: login()
mainform
8: relogin

2: enter username/password
user loginform

3: authentication

7: error message

welcomeform logincontroller errormessage

6: invalid
5: valid

4: enter into database

database

View reports collaboration diagram:-

2: enter id

6: re_enter id 3: verification
administrator mainform controller

1: requestid

8: generate reports

database
7: verified

4: invalid id
5: error message

errormessage

View stock collaboration diagram:-


1: request book details 2: verify
user main form  controller
administrator

6: retrieved data

database 5: verified
3: not filled properly

4: error message

error
message

Maintain book stock :-

manager option

1: to avail option

2: add books
3: update books
4: delete books

book profile 
form

Add books collaboration diagram:-


2: add new books 3: verification
manager new book  book 
add form controller
1: request for new book

7: generate id

database
6: filled properly

4: not filled property
5: error message

errormessage

Modify collaboration diagram:-

2: selecting book
manager selector  modification 
form controller
1: request to select book

6: verification
5: modifying

3: intimate database
modification 
form

7: improper modification 4: retrive database

error  8: error messages database


message

Delete collaboration diagram:-


1: select book
manager selector 
form

3: deleting
2: retriving data

4: update()
deletion  database
form
6. PC Model
7. Plant Model
8. Point Of Sale :
Sequence diagram:-

cashier system tax collector credit authorization accounts


service
1: make new sales()

2: enter item()

3: description()

4: end sales()

5: taxline items = getTaxes()

6: total wih Taxes()

7: make payment()

8: change receipt()

9: reply = request approval()

10: post receivable

11: post sales

Collaboration diagram:-
cashier tax collector

1: make new sales

2: enter items 5: tax line item = getTaxes

8: change receipt

4: end sales
6: total with taxes

7: make payments

3: description

system
10: post receivable

11: post sales

9: reply = request approval

accouts
credit authorization service
9. Simulated Company
Sequence Diagram for usecase – 1:

:user disp : Display :Loan amount : Cash details : Compan


Account yDetails
requestLoan()

getDetails

returnDetails()

Loan(amt,dur)

credit(amt)

updateDisplay()

balance()

amount

Sequence diagram for usercase 2:


:user disp : Display amount : Cash MachineClass factory : Factory
Account

purchaseMachine()

balance()

amount()

getStaticDetails()

cost, overload, output, rawcost

howManyMachines()

numberOfMachines

confirm

debitCost

updateDisplay()
addMachine(Machine)

balance()

amount
Simulated company for usecase 3:
:User disp:Display factory:Factory MachineClass market:Market production:Prod sales:Sales
uction
nextTurn

capacity

mcoutput

output

number

projectedPrice()

nextTurn(numbertaken,price,s alesprice)

getProductionDetails()

recordNumber()

recordSalesPrice()

getNumberInStock()

stock

getProjectedPrice()

projectedPrice()

getProjectedSales()

projectedSales()

adjustProjectedPrice()

setEndStock(number)

adjustProjectedSales() recordNumberSold(count)

calculate

gros sProfit()
Instance level collaboration diagram:

1: Create
2: setBalance(amount)

: Simco Cash : CashAccount

3: Create
Prod : ProductionRun
4: Create

factory : Factory
5: Create

market : Market
6: Create

sales : Sales
7: Create

details : CompanyDetails
8: Create
disp : Display

Specification level collaboration diagram:-

:Simco /CompanyAccount : 
CashAccount

/CompanyProductionRu
n : ProductionRun

/ProductionFactor
y : Factory

/MarketDetails : 
Market

/SalesDetails : 
Sales

/CompanyDetails : 
CompanyDetails

/UserDisplay : 
Display

Instance level collaboration diagram for usecase 1:


: User

1: RequestLoan

2: 3 : Loan ( amount,duration) 3: 5 : addLoan(Loan)
disp :  : Loan details : Company
Display Details

cash : Cash
Account

Specification level collaboration for usecase – 1:

/UserDisplay : 
Display

1...*

1...* Loan 1...*

/CompanyAccount :  /companyDetails : 
CashAccount CompanyDetails

Instance level collaboration diagram for usecase – 2

:User

1: Purchase Machines :Machine
3: cost = mCost() Class
disp : Display 4: output = moutput()
5: o_h : mOverhead()
6: rawCost : mcrawcost()
2: Balance()
8: Machine
7: numberOfMachines := howManyMachines()

cash : CashAccount :Machine factory : Factory

9: debit(cost)
10: addMachine(Machine)
Specification level collaboration for usecase 2:

/UserDisplay :  1...* :Machine


Display Class

1...*

1...* Machine 1...*

/ProductionFactor
/CompanyAccount :  y : Factory
CashAccount

Instance level collaboration for usecase 3:

Instance level collaboration for usecase 4:


disp : 
Display

1: doMonthlyAccounts()

details : Company
Details

2: o_h = machineOverhead() 7: adjustBank()
6: amount := grossProfit() 8: credit(new Profit())

cash : Cash
factory :  sales :  Account
Factory :Loan
Sales

4: adjustDuration()
5: repayment := showRepayment()
3: o_h := moverhead()

:Machine
Class

Specification level collaboration for usecase 4:

/UserDisplay : 
Display

:Loan

/ProductionFactor /CompanyDetails :  /CompanyAccount : 


y : Factory CompanyDetails CashAccount

:Machine
Class /SalesDetails : 
Sales

Specification level collaboration diagram for usecase 5:


/UserDisplay : Display

/MarketDetails : 
/CompanyDetails :  Market
CompanyDetails

/CompanyAccount :  /ProductionFactor
CashAccount y : Factory

/SalesDetails :  /CompanyProduction : 
Sales Production
10. Class Room Model
11. Telephone Dialing
Sequence diagram :-

caller exchange talker

1: lift receiver

2: dialtone

3: dial digit

4: route

5: phone ring

6: ringing tone

7: answer phone

8: stop ringing

9: stop tone

Collaboration diagram:-
1: lift receiver 3: dial digit 4: route
caller exchange

9: stop tone 6: ringing tone 2: dialing

5: phone rings

8: stop ringing
7: answer phone

talker

You might also like