Ooad Lab Programs

  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Ooad Lab Programs as PDF for free.

More details

  • Words: 11,244
  • Pages: 80
Object oriented analysis and design lab report

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); } } Department of MCA ,MSRIT,Bangalore.

1

Object oriented analysis and design lab report

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 windowClosing(WindowEvent we) { System.exit(0); } } public static void main(String s[]) { Design1 d1=new Design1(); d1.setSize(500,500); d1.setVisible(true); } } Department of MCA ,MSRIT,Bangalore.

2

Object oriented analysis and design lab report

PROBLEM 4 Problem 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.

Department of MCA ,MSRIT,Bangalore.

3

Object oriented analysis and design lab report

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.

Department of MCA ,MSRIT,Bangalore.

4

Object oriented analysis and design lab report

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

Accep t/De cline O ffe r <<Extends>>

Candidate

A ward Bonus

Department of MCA ,MSRIT,Bangalore.

5

Object oriented analysis and design lab report

USE CASES: Use Case: Description : Flow of Events: Pre-Condition: Post-Condition: Use Case: Description: Flow of Events: Pre-Condition: Post-Condition:

Notify Vacancy This Use Case is initiated by HR and the Employee. Notifies about the vacancies to employees of the region. 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. Vacancy must exist. Details about the vacancy are informed. Filling of Forms 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. 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. Online form must exist. 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: Description

Flow of Events:

Pre-Condition: Post-Condition

Short Listing of Candidates 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. 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. Candidate must meet eligibility criteria. Candidate must be referenced by the employee of that organization. Candidate clears interview process. OR Candidate doesn’t clear interview process.

Department of MCA ,MSRIT,Bangalore.

6

Object oriented analysis and design lab report Use Case : Description: Flow of Events Alternate Flow

Pre-Condition: Post-Condition:

Intimation to the selected candidates. 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. 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. 1. Candidate rejects the offer letter. 2. Candidate application is rejected. 3. No Bonus is awarded to the employee who referred the candidate. Candidate is selected for the job. 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:

: HR Head

Email System

: Employee

1: Informs about Vacancy 2.Recieves Vacancy Information

Department of MCA ,MSRIT,Bangalore.

7

Object oriented analysis and design lab report

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:

: HR Head

IS

Online Interview System

: Candidate

1: Initiate Interview 2: Reply to the Queries 3: Receives reply

4: Stores Shortlisted Candidate Detai ls

Department of MCA ,MSRIT,Bangalore.

8

Object oriented analysis and design lab report

Intimation [Accepts Offer Letter]:

: HR Head

Email System

: Candidate

: Employee

1: S ends Offer Letter 2: Receives Offer Letter

3: A ccepts Offer Letter 4: Recieves Acceptance

5: Informs about bonus awarded 6: Recieve s B onus Noti fi cation

Intimation [Rejection]:

: HR Head

Emai l System

: Candidate

1: sends offer Letter

2: recieves Offer Letter

3: Reject Offer Letter 4: recieves the rejection

Department of MCA ,MSRIT,Bangalore.

9

Object oriented analysis and design lab report

CLASS DIAGRAM

Employee Fname : String LName : String Emp-ID : int Designation : String region : string

H R Hea d

ReferCandidate() GetBonus()

Maintainence Employee e Candidate c

Employee e Candidate c

Insert() Update() Delete()

InformVacancy() ConductInteview() ShortList Candidates() Intimate Candidates()

Vacany Details JobCode : int Designati on : St ri ng Descri pti on : S tring No. ofVacant Pos : i nt Prerequi sit s()

Candidate Fname : String LName : string CandidateID : int JobCode : int apply()

Selected Candidates Candi dateID : i nt Accep t() Reject()

Department of MCA ,MSRIT,Bangalore.

Recruited Candidates CandidateID : int FillVacancy()

10

Object oriented analysis and design lab report

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 conduct 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.

Department of MCA ,MSRIT,Bangalore.

11

Object oriented analysis and design lab report

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.

Department of MCA ,MSRIT,Bangalore.

12

Object oriented analysis and design lab report

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>>

faculty

student 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. Alternate flow of event: 5. Post condition:

-

Department of MCA ,MSRIT,Bangalore.

13

Object oriented analysis and design lab report 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. Alternate 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. Alternate flow of event: 5. Post condition: -

Department of MCA ,MSRIT,Bangalore.

14

Object oriented analysis and design lab report

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

Department of MCA ,MSRIT,Bangalore.

15

Object oriented analysis and design lab report 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 student Sname Regno Marks1 Marks2 Marks3 Total Student.S[3] student () display()

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.

Department of MCA ,MSRIT,Bangalore.

16

Object oriented analysis and design lab report 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"); }

Department of MCA ,MSRIT,Bangalore.

17

Object oriented analysis and design lab report 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(); } }

Department of MCA ,MSRIT,Bangalore.

18

Object oriented analysis and design lab report

PROGRAM 6 Problem 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 total 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 considered 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.

Department of MCA ,MSRIT,Bangalore.

19

Object oriented analysis and design lab report 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

<>

<>

ENTER MARKS <>

VIEW REPORTS

FACULTY

MARKS PROCESSING

Usecase documentation: 1 Usecase name: Login The users of the system either faculty or student interact with the through a login process to verify their authentication.

system by going

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.

Department of MCA ,MSRIT,Bangalore.

20

Object oriented analysis and design lab report Alternate 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. Alternate 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. Alternate flow 3: Display error message, re-enter marks. Postcondition: Enter marks are verified and are stored to perform processing. 4.Usecase name: View 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. Alternate flow 4: Display error message, reenter register number. Postcondition: Result of the student is displayed in a formatted manner.

Department of MCA ,MSRIT,Bangalore.

21

Object oriented analysis and design lab report

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

Department of MCA ,MSRIT,Bangalore.

22

Object oriented analysis and design lab report 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 Viewing 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

Department of MCA ,MSRIT,Bangalore.

23

Object oriented analysis and design lab report Class Diagram

Subject Sub_name : String Sub_code : String theory_max : Integer theory_min : Integer lab_max : Integer lab_min : Integer

Derives Subject Info Derives Subject Info Student Regno : Integer Name : String Marks[] : Integer Subject[] : String total : Integer result : String

Faculty

Provides Marks details

student_login() get_details() get_marks() compute_result() view_reports()

sub1[] : Integer sub2[] : Integer sub3[] : Integer sub4[] : Integer sub5[] : Integer sub6[] : Integer faculty_login() get_regno() enter_marks()

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.

Department of MCA ,MSRIT,Bangalore.

24

Object oriented analysis and design lab report

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
Department of MCA ,MSRIT,Bangalore.

25

Object oriented analysis and design lab report

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 }

Department of MCA ,MSRIT,Bangalore.

26

Object oriented analysis and design lab report 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"); } }

Department of MCA ,MSRIT,Bangalore.

27

Object oriented analysis and design lab report

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){ } } }

Department of MCA ,MSRIT,Bangalore.

28

Object oriented analysis and design lab report

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 Operator: 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.

Department of MCA ,MSRIT,Bangalore.

29

Object oriented analysis and design lab report 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"); } }

Department of MCA ,MSRIT,Bangalore.

30

Object oriented analysis and design lab report 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. Alternative 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: View 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.

.

Department of MCA ,MSRIT,Bangalore.

31

Object oriented analysis and design lab report

Usecase Diagram

Display TV Models <<uses >>

Operator

Aut hent icat ion

Display Price List

Classes

TV make : char size : char purchase_date : int color : bool

Transaction Manager id : char

<----- password : char verify()

TV() Display() Check()

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.

Department of MCA ,MSRIT,Bangalore.

32

Object oriented analysis and design lab report 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 considering 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

Department of MCA ,MSRIT,Bangalore.

33

Object oriented analysis and design lab report

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

Department of MCA ,MSRIT,Bangalore.

34

Object oriented analysis and design lab report

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.

Department of MCA ,MSRIT,Bangalore.

35

Object oriented analysis and design lab report

USE CASE :

Verify Account

Account Holder

D eposi t

Administrator

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

Department of MCA ,MSRIT,Bangalore.

36

Object oriented analysis and design lab report  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.

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. Alternate Flow 1: Requested pin number again. Alternate 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. Alternate Flow: 1. Balance remains unchanged. Post-Condition: The amount is deposited to the respective account type and balance is updated. Calculate Interest: 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. Department of MCA ,MSRIT,Bangalore.

37

Object oriented analysis and design lab report 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: 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. Alternate 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. Alternate Flow: No Alternate Flow. Post-Condition: The Transaction is successful and completed. CLASS DIAGRAM

Department of MCA ,MSRIT,Bangalore.

38

Object oriented analysis and design lab report

Account Holder Name Address Phone Account Number Pin Number

Administrator Account Holder Number Account Holder Name Amount Rate of Interest Validate User() Calculate Interest() Display Output()

Enter Pin() Deposit()

Deposit Principle Rate of Interest Number of years Simple Interest Amount Deposit()

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 holder. 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.

Department of MCA ,MSRIT,Bangalore.

39

Object oriented analysis and design lab report

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); Department of MCA ,MSRIT,Bangalore.

40

Object oriented analysis and design lab report } } 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;

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); } }

Department of MCA ,MSRIT,Bangalore.

41

Object oriented analysis and design lab report 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(); } } 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 constructed 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 name

User ID

Fname

Uname

Street

City

State

DOB

ADD

Phone no

Address Object name

Department of MCA ,MSRIT,Bangalore.

Country

Pin code

42

Object oriented analysis and design lab report

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: Customer ID: First name: Last name: DOB: Address: Phones: Customer ID: First name: Last name: DOB: Address: Phones: No of users: Deposit: Principle: Rate of interest: No of years: Simple interest: Amount: Problem Statement: • • • • • • • •

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.

Department of MCA ,MSRIT,Bangalore.

43

Object oriented analysis and design lab report • • • •

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 2 3 4 5 6 7 8 9

The bank client must be able to deposit amount into his/her account. Recorded transaction must include date, time, amount and account balance after transaction. Customers can have more than one account. The bank application operates for single banking institutions only. 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. The system must be able to get number of customers at any time. The system must provide security. There are three types of accounts they are savings, current and joint. More than one customer can share account.

Department of MCA ,MSRIT,Bangalore.

44

Object oriented analysis and design lab report 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

BIS

Clerk

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 Verification and validation of account number, user id authenticated by clerk through BIS.

PRE-CONDITION

Department of MCA ,MSRIT,Bangalore.

45

Object oriented analysis and design lab report NORMAL FLOW

ALTERNATIVE FLOW POST CONDITION

1.Enter account number 2.Valid account number 3.Enter customer id. 4.Valid customer id. 5.Enter amount for deposit (cash). Not authenticated. Update of transaction. (2)

USE CASE NAME DESCRIPTION

:

PRE-CONDITION NORMAL FLOW ALTERNATIVE FLOW POST CONDITION

INTEREST CALCULATION This use case is initiated by bank clerk. It calculates the simple interest and updates the balance amount. Verification and validation of account number, user id authenticated by clerk through BIS. Calculation of simple interest. Not authenticated. Update Balance.

CLASS DIAGRAM : Analysis Phase:

Customer Customer_id First_Name Last_Name DOB Phone_No Address

Has Shared

Display()

Account Acc_no Acc_Type No_Of_Users Start_Date Deposit Customer Deposit_Amt() GetNoOfUsers()

Contains

Address Street City State Country Pincode

Deposit Principle No_Of_Yeras Rate_Of_Interest

Display()

Interest_Calculation()

Department of MCA ,MSRIT,Bangalore.

46

Object oriented analysis and design lab report

Design Phase: Customer Customer_id : String First_Name : String Last_Name : String DOB : Integer Phone_No : Integer Address : Address Addr

Has Shared

Account Acc_no : Long Acc_Type : String No_Of_Users : Integer Start_Date : String Deposit : Deposit Dep Customer : Customer Cust Deposit_Amt() GetNoOfUsers()

Display()

Contains

Address Street : String City : String State : String Country : String Pincode : Integer

Deposit Principle : float No_Of_Yeras : Integer Rate_Of_Interest : Integer Interest_Calculation()

Display()

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.

Department of MCA ,MSRIT,Bangalore.

47

Object oriented analysis and design lab report

Problem No: 10 Consider the object college of mini project for the entire given specification 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

4.

a)

Sequence Diagram

b)

Collaboration Diagram

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. 2. 3.

Lab User Maintenance Person 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.

Department of MCA ,MSRIT,Bangalore.

48

Object oriented analysis and design lab report

Use Case Diagram:

Authentication Maintenance person

Database

<<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 Alternate 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.

Department of MCA ,MSRIT,Bangalore.

49

Object oriented analysis and design lab report 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. View 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 person

Database

: loginForm

1: Enter id and password 2: Verify

3: Verification

4: Valid user

Department of MCA ,MSRIT,Bangalore.

50

Object oriented analysis and design lab report 2. Sequence diagram for Update: Maintenance person

Database

: 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 View details: User

Database : vi ewdetai lsForm 1: Request details 2: Check database

3: Retrieve 4: Send details 5: Display details

Department of MCA ,MSRIT,Bangalore.

51

Object oriented analysis and design lab report

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 View details:

User

1: Request details 5: Display details

: viewdetailsForm

4: Send details 3: Retrieve

2: Check database

D atabase

Class diagram: Department of MCA ,MSRIT,Bangalore.

52

Object oriented analysis and design lab report

College Name Address Software License No of copies Validity

Display() Lab Lab-id Get_equipment_details()

check_validity() Equipment Equipment-id Purchase-date Warranty

Peripherals Make Type of device Get_type_of_device()

Get_details()

Terminal Terminal-configuration

Server Server-configuration

Get_configuration()

Get_configuration()

Class diagram documentation: 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 Server

Client Machine LAN

Deployment diagram documentation: Database will be stored in the server and will be accessed by the user through LAN.

Department of MCA ,MSRIT,Bangalore.

53

Object oriented analysis and design lab report

Program11: C Library Information System Problem Statement: 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. Alternative Flow: If book is not available then reserved book use case should be initiate. Post Condition: Update the catalogue.

Department of MCA ,MSRIT,Bangalore.

54

Object oriented analysis and design lab report

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. Alternative 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. Alternative 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.

Department of MCA ,MSRIT,Bangalore.

55

Object oriented analysis and design lab report

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.

Department of MCA ,MSRIT,Bangalore.

56

Object oriented analysis and design lab report

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 Manager

1: Query For Outdated / Damaged Books 3: display damaged book_id

Department of MCA ,MSRIT,Bangalore.

Lib Info System

57

Object oriented analysis and design lab report

SEQUENCE DIAGRAM FOR BORROWING BOOKS Librarian 1: Verify Id

Lib Info System

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 4: Get book_id

2: Get File 5: Update

3: Valid User 6: Issue Book Lib Info System

Department of MCA ,MSRIT,Bangalore.

58

Object oriented analysis and design lab report

DIAGRAM FOR RESERVE BOOKS Librarian

Lib Info System 1: Verify Id 2: Get File 3: Valid User 4: Get book_id 5: C heck for avai labili ty 6: Display Unavailable 7: request for reserve book

8: Reserve

COLLOBRATION DIAGRAM FOR RESERVE

Librarian

1: Verify Id 4: Get boo k_id 7: request for reserve book

3: Valid User 6: Display Unavai lable

2: Get Fi le 5: C heck for availability 8: Reserve

Lib Info System

Department of MCA ,MSRIT,Bangalore.

59

Object oriented analysis and design lab report

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

Department of MCA ,MSRIT,Bangalore.

60

Object oriented analysis and design lab report Activity diagram for library

Verify Id

Book_id

[ Return book ]

[ Valid Member ]

[ invalid ]

[ Borrow book ]

Not a Valid User

Enter book_id Update &check for fine

[ No ] Book Available

Reserve Book

[ Yes ]

Check for reserve

Issue Book and Update

Class Diagram Member Member_id Name Address No_of_book

Catalogue Transaction has

Add_member() Remove() Display() Search() Update()

participates

Book_id Member_id Get_Bookid() Get_memberid() Get_Permission()

Borrow Last_date Issue() Display() Search() Reserve()

Department of MCA ,MSRIT,Bangalore.

Return Update() Check() Reserve()

Id Price Author Publisher Add() Delete() Search() Display()

Book

Magazines

Isbn

Type

Condition()

Add_Type()

61

Object oriented analysis and design lab report

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) Member: Contains all the information about member such as name,address, The no. of book particular member has etc. Component Diagram

Member

Transaction

Catalogue

Transaction: This Component consists of Borrow, Return class. Member: This component consists Member class Catalogue: This component consists of Book and Magazines Class.

Department of MCA ,MSRIT,Bangalore.

62

Object oriented analysis and design lab report

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:

Department of MCA ,MSRIT,Bangalore.

63

Object oriented analysis and design lab report Railway Reservation System

updating information and display availabi lity of tickets <<uses>>

Railway Reservation staff

Database Train Information

Processing Reservation form <<extends>>

issuing of tickets

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 train 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. 2. 3. 4.

Enter the source station Enter the destination station Enter the Train no. Enter the Train name.

Department of MCA ,MSRIT,Bangalore.

64

Object oriented analysis and design lab report 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. Alternative Flow 1: Display that the reservation is not available. 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 Alternative Flow 1: Display the details to re-enter the missed details. Post-condition: The customer will be issued the ticket. 4. Issuing ticket:

Department of MCA ,MSRIT,Bangalore.

65

Object oriented analysis and design lab report 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. 2. 3. 4. Post Condition:

Check the details of passenger. Give print message to the printer. The ticket is issued. Database is updated.

The ticket is issued and is collected by the passenger.

Sequence diagram of train information

Department of MCA ,MSRIT,Bangalore.

66

Object oriented analysis and design lab report 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 staff

form

7: display the train info 6: proc ess the info 5: submit the details printer database

Activity diagram of train information

Department of MCA ,MSRIT,Bangalore.

67

Object oriented analysis and design lab report

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

Department of MCA ,MSRIT,Bangalore.

68

Object oriented analysis and design lab report 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

Department of MCA ,MSRIT,Bangalore.

69

Object oriented analysis and design lab report 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 staff

form

9: display the availability 8: process the info 7: submit the info

database

Department of MCA ,MSRIT,Bangalore.

printer

70

Object oriented analysis and design lab report

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

Department of MCA ,MSRIT,Bangalore.

display not available

71

Object oriented analysis and design lab report 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

Department of MCA ,MSRIT,Bangalore.

72

Object oriented analysis and design lab report Collaboration diagram of processing reservation form

railway staff

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 10: enter the address

form

13: display the amount to be paid

12: process the info

11: submit the info

printer database

Department of MCA ,MSRIT,Bangalore.

73

Object oriented analysis and design lab report Sequence diagram of issuing ticket railway staff

form

database

printer

1: enter the passenger details

2: submit the form

3: check the passenger detai ls

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

Department of MCA ,MSRIT,Bangalore.

74

Object oriented analysis and design lab report

Collaboration diagram of issuing ticket 1: enter the passenger details 5: reenter the details railway staff

3: check the passenger details 7: process the info 9: update the database

form

4: display invalid details

2: submit the form 6: submit the form 8: print the ticket database

Department of MCA ,MSRIT,Bangalore.

printer

75

Object oriented analysis and design lab report Activity diagram of issuing ticket

enter the trai n 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

Department of MCA ,MSRIT,Bangalore.

76

Object oriented analysis and design lab report

Class diagram:

Passenger Name age sex address

Form source_station destination_station date_of_journey class_of_coach no_of_passengers get_passenger_detail() get_train_detail()

Ticket ticket_no departure_time amount

train train_no train_name

calculat e_fare() print_ticket()

Department of MCA ,MSRIT,Bangalore.

77

Object oriented analysis and design lab report 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()

Department of MCA ,MSRIT,Bangalore.

78

Object oriented analysis and design lab report { 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);

Department of MCA ,MSRIT,Bangalore.

79

Object oriented analysis and design lab report 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"); } } }

Department of MCA ,MSRIT,Bangalore.

80

Related Documents

Ooad Lab Programs
November 2019 7
Ooad Programs
June 2020 0
Lab Programs
November 2019 20
Ooad
November 2019 23
Ooad
April 2020 15
Ooad
May 2020 10