Top Banner

of 50

OOPS ALL Assignment

Apr 06, 2018

Download

Documents

Pranjal Goyal
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • 8/3/2019 OOPS ALL Assignment

    1/50

    OOP SYSTEM 2010

    [SWADESH JAIN] [AB-34077] [ BATCH B-3] Page 1

    LAB ASSIGNMENT # 1OBJECT ORIENTED PROGRAMMINGSYSTEMQUE 1 : WAP FOR THE FOLLOWING ALL ARITHMETIC OPERATION :ADDITION , SUBTRACTION , MULTIPLICATION , DIVISION , MODULUS

    ANS:

    import java.io.*;class Arithmatic_CMDUser{public static void main(String args[]){ double a=0,b=0;

    long x=0,y=0;int ch=0;BufferedReader br=new BufferedReader(new InputStreamReader(System.in));Arithmatic ar=new Arithmatic();ar.showMenu();

    try{do

    {System.out.println("enter choice");// get the user's choice of operation.ch=Integer.parseInt(br.readLine());// take two double no.s forif(ch==1||ch==2||ch==3||ch==4)

    {System.out.println("enter first number");

    a=Double.parseDouble(br.readLine());System.out.println("enter second number");b=Double.parseDouble(br.readLine());

    }

    switch(ch){case 1:

    System.out.println("sum is= "+ar.add(a,b));break;

    case 2:System.out.println("difference is = "+ar.subtract(a,b));

    break;

    case 3:System.out.println("product is= "+ar.multiply(a,b));break;

    case 4:System.out.println("quotient is= "+ar.divide(a,b));

    break;case 5:

    System.out.println("enter first number");x=Long.parseLong(br.readLine());System.out.println("enter second number");

  • 8/3/2019 OOPS ALL Assignment

    2/50

    OOP SYSTEM 2010

    [SWADESH JAIN] [AB-34077] [ BATCH B-3] Page 2

    y=Long.parseLong(br.readLine());System.out.println("mod is= "+ar.mod(x,y));

    break;case 6:

    System.exit(0);break;

    default:System.out.println("wrong choice:\n please enter number any no 1-5 ");}System.out.println("press y to continue") ;}while(br.readLine().equalsIgnoreCase("y"));

    }catch(IOException e){

    System.out.println(e.toString());}catch(NumberFormatException e){

    System.out.println("invalid numbers");}

    }}

    QUE 2 : WAP FOR THE FOLLOWING

    # FIND THE LARGEST AMONGS THREE STRINGS.

    # CHECK THE STRING IS PALINDROM OR NOT.

    # IDENTIFY THE VOWELS AND CONSONANT.

    ANS :

    import java.io.*;class Stringop{void largest(String s1,String s2,String s3){

    if(s1.length()>s2.length()){

    if(s1.length()>s3.length()){System.out.println("The largest string is"+s1);

    }else

    System.out.println("The largest string is"+s3);}else{

    if(s2.length()>s3.length()){System.out.println("The largest string is:"+s2);

    }elseSystem.out.println("The largest string is:"+s3);

  • 8/3/2019 OOPS ALL Assignment

    3/50

    OOP SYSTEM 2010

    [SWADESH JAIN] [AB-34077] [ BATCH B-3] Page 3

    }}

    void isvowel(char x){

    switch(x){

    case 'a':System.out.println("vowel");break;

    case 'e':System.out.println("vowel");break;

    case 'i': System.out.println("vowel");break;

    case 'o' : System.out.println("vowel");

    break;

    case 'u': System.out.println("vowel");break;

    default:System.out.println("consonant");

    }}String palindrome(String s1){

    String s2= new StringBuffer(s1).reverse().toString();

    if(s1.equals(s2)){return "palindrome";

    }else

    return "not a palindrome";}}class Stringdemo{public static void main(String args[]) throws Exception{

    Stringop s= new Stringop();BufferedReader br= new BufferedReader(new InputStreamReader(System.in));char c;String str;int m=0;

    do{

    System.out.println("Enter the operation u want to perform on strings:");System.out.println("1.find the largest string 2.find vowel or consonant 3.palindrome");

    int a= Integer.parseInt(br.readLine());

  • 8/3/2019 OOPS ALL Assignment

    4/50

    OOP SYSTEM 2010

    [SWADESH JAIN] [AB-34077] [ BATCH B-3] Page 4

    switch(a){

    case 1:System.out.println("Enter the first string:");String x= br.readLine();System.out.println("Enter the second string:");

    String y= br.readLine();System.out.println("Enter the third string:");

    String z= br.readLine();s.largest(x,y,z);break;

    case 2:System.out.println("enter any character:");c=(char)br.read();s.isvowel(c);break;

    case 3:

    System.out.println("Enter any String:");str= br.read();System.out.println(s.palindrome(str));

    break;

    default:System.out.println("wrong entry");

    }System.out.println("Do you want to continue?");

    System.out.println("1.yes 2.no");

    m=Integer.parseInt(br.readLine());}while(m==1);}}

    QUE 3 : WAP TO IDENTIFY THE TYPE OF TRIANGLE WHETHER IT IS SCALENE OR

    ISOSCALENE OR EQUILATERAL.

    ANS :

    import java.io.*;class Tritype{

    String whichtri(int a,int b,int c){

    if((a!=b)&&(b!=c)&&(c!=a)){

    return "scalene";}

  • 8/3/2019 OOPS ALL Assignment

    5/50

  • 8/3/2019 OOPS ALL Assignment

    6/50

    OOP SYSTEM 2010

    [SWADESH JAIN] [AB-34077] [ BATCH B-3] Page 6

    {double z= (0.5)*(x*y);return z;

    }

    double traparea(double x,double y,double z)

    {double w= (0.5)*(x+y)*z;return w;

    }double kitearea(double x,double y){

    double v= (x*y)+(0.5*x*y);return v;

    }}class Areademo{public static void main(String args[]) throws Exception

    {FindArea f= new FindArea();double base=50;double width=50;double height=30;

    BufferedReader br= new BufferedReader(new InputStreamReader(System.in));System.out.println("Enter the figure for which u want the area?");System.out.println("1.square 2.rectangle 3.paralleogram 4.triangle 5.trapezium 6.rhombus 7.kite");int a= Integer.parseInt(br.readLine());switch(a){

    case 1:System.out.println("the area of square taking base=50 is:");

    System.out.println(f.sqarea(base));break;

    case 2:System.out.println("the area of rectangle having length 50 and width 30 is:");

    System.out.println(f.figarea(base,height));break;

    case 3:System.out.println("the area of paralleogram having base 50 and height 30 is:");

    System.out.println(f.figarea(base,height));break;

    case 4:System.out.println("the area of triangle having base 50 and height 30 is:");System.out.println(f.triarea(base,height));break;

    case 5:System.out.println("the area of trapezium having parallel sides 50,30 and height 50 is:");

    System.out.println(f.traparea(base,height,width));break;

    case 6:System.out.println("the area of rhombus having base 50 and height 30 is:");

  • 8/3/2019 OOPS ALL Assignment

    7/50

    OOP SYSTEM 2010

    [SWADESH JAIN] [AB-34077] [ BATCH B-3] Page 7

    System.out.println(f.figarea(base,height));break;

    case 7:System.out.println("the area of kite having base 50 and height 30 is:");System.out.println(f.kitearea(base,height));

    break;default:

    System.out.println("wrong entry");}

    }}

    QUE 5 : WAP FOR FINDING THE VALUES FOR FOLLOWING TRIGNOMETRIC

    FUNCTIONS TAKE BASE= 50mm, PERPENDICULAR= 60mm, HYPOTENIS= 90mm.

    # SINE

    # COSINE# TANGENT

    # COSECANT

    # SECANT

    # COTANGENT

    ANS :

    import java.io.*;class Trigfunctions{

    double trig(int a,int b)

    {double c;c=(a/b);return c;

    }}class Trigdemo{public static void main(String args[]) throws Exception{

    Trigfunctions tr= new Trigfunctions();BufferedReader br= new BufferedReader(new InputStreamReader(System.in));int p=60;

    int b=50;int h=90;

    System.out.println("enter the operation u want to perform?");System.out.println("1.sine 2.cosine 3.tangent 4.cosecant 5.secant 6.cotangent");

    int c= Integer.parseInt(br.readLine());switch(c){

    case 1:

  • 8/3/2019 OOPS ALL Assignment

    8/50

    OOP SYSTEM 2010

    [SWADESH JAIN] [AB-34077] [ BATCH B-3] Page 8

    System.out.println("sine");System.out.println(tr.trig(p,h));break;

    case 2:System.out.println("cosine");

    System.out.println(tr.trig(b,h));break;

    case 3:System.out.println("tangent");System.out.println(tr.trig(p,b));break;

    case 4:System.out.println("cosecant");System.out.println(tr.trig(h,p));break;

    case 5:

    System.out.println("secant");System.out.println(tr.trig(h,b));break;

    case 6:System.out.println("cotangent:");System.out.println(tr.trig(b,p));break;

    default: System.out.println("wrong entry");}

    }}

    QUE 6 : WAP FOR CALCULATING FOLLOWING STATISTICAL FUNCTIONS TAKE

    13, 18, 13, 14, 13, 16, 14, 21, 13

    # MEAN

    # MEDIAN

    # MODE

    # RANGE

    ANS :

    import java.io.*;

    import java.util.*;class Number{

    double d;int f;Number(double a,int b){ super();

    d=a;f=b;

    }

  • 8/3/2019 OOPS ALL Assignment

    9/50

    OOP SYSTEM 2010

    [SWADESH JAIN] [AB-34077] [ BATCH B-3] Page 9

    }public class Statistic{ double p=Math.pow(10, 4);

    public double mean(double values[]){double sum=0;

    for(int i=0;i=0)){

    ++count;

    l.remove(i);}return count;

    }

    public List mode(ArrayList al){

    int max=0;Collections.sort(al);ArrayList modes=new ArrayList();//this is the list which this method is going to returnTreeSet treeset=new TreeSet(al); // treeset contains all unique elements i.e. frequency=1Stack s=new Stack();

    s.push(new Number(0.0,0));for(Double d:treeset)

    { max=s.peek().f; //topmost element of stack has the highest frequencyint i=getFrequency(al,d);// for each uniqye element in treeset find its frequencyif(i>=max){

    max=i; // if the frequency of current element is greater than or equal to the max than push it to stack.s.push(new Number(d,max));

    }}

  • 8/3/2019 OOPS ALL Assignment

    10/50

    OOP SYSTEM 2010

    [SWADESH JAIN] [AB-34077] [ BATCH B-3] Page 10

    // finally pop the elements from stack till top of stack has the max frequncywhile(s.peek().f==max){

    modes.add(s.pop());}

    return modes;}

    //------------------------------------------// sort the array using bubble sort.

    public void sort(double x[]){ double temp;

    for(int i=0;i

  • 8/3/2019 OOPS ALL Assignment

    11/50

    OOP SYSTEM 2010

    [SWADESH JAIN] [AB-34077] [ BATCH B-3] Page 11

    al_in = new ArrayList();for(int i=0;i

  • 8/3/2019 OOPS ALL Assignment

    12/50

    OOP SYSTEM 2010

    [SWADESH JAIN] [AB-34077] [ BATCH B-3] Page 12

    ANS :

    import java.io.*;class ArithmeticProgression{ int p[],n;public int [] generateAP(int a,int d,int n)

    { this.n=n;p=new int[n];p[0]=a;

    for(int i=1;i

  • 8/3/2019 OOPS ALL Assignment

    13/50

    OOP SYSTEM 2010

    [SWADESH JAIN] [AB-34077] [ BATCH B-3] Page 13

    int ch=0,a=0,r=0,d=0,n=0;try{do{

    System.out.println("enter choice");

    ch=Integer.parseInt(br.readLine()) ;System.out.println("enter first term");a=Integer.parseInt(br.readLine());System.out.println("enter no of terms");n=Integer.parseInt(br.readLine());

    switch(ch){

    case 1:System.out.println("enter Common Difference");d=Integer.parseInt(br.readLine());ArithmeticProgression ap=new ArithmeticProgression();

    ap.generateAP(a,d,n);ap.showAP();

    break;case 2:

    System.out.println("enter Common Ratio");r=Integer.parseInt(br.readLine());GeometricProgression gp=new GeometricProgression();

    gp.generateGP(a,r,n);gp.showGP();

    break;default:

    System.out.println("wrong choice");

    }

    System.out.println("to continue press y");}while(br.readLine().equalsIgnoreCase("y"));

    }catch(IOException e){

    System.out.println(e.toString());}

    catch(NumberFormatException e){

    System.out.println("invalid numbers");}

    }}

    QUE 8 : WAP FOR THE FOLLOWING

    #SUM OF SQUARE OF GIVEN EVEN NUMBERS FROM 1 TO 20

    #SUM OF SQUARE OF GIVEN ODD NUMBERS FROM 21 TO 40

    ANS :

  • 8/3/2019 OOPS ALL Assignment

    14/50

    OOP SYSTEM 2010

    [SWADESH JAIN] [AB-34077] [ BATCH B-3] Page 14

    import java.io.*;public class Sum{

    public int sumOfSquaresOfEven(int n){ int sum=0;

    for(int i=1;i

  • 8/3/2019 OOPS ALL Assignment

    15/50

    OOP SYSTEM 2010

    [SWADESH JAIN] [AB-34077] [ BATCH B-3] Page 15

    QUE 9 : WAP FOR THE FOLLOWING

    A STUDENT PURCHASES A COMPUTER BY OBTAINING A SIMPLE INTEREST

    LOAN. THE COMPUTER COSTS Rs. 1500, AND THE INTEREST RATE ON THE LOAN IS12%. IF THE LOAN IS TO BE PAID BACK IN WEEKLY INSTALMENTS OVER 2 YEARS,

    CALCULATE

    # THE AMOUNT OF INTEREST PAID OVER THE 2 YEARS,

    # THE TOTEL AMOUNT TO BE PAID BACK,

    # THE WEEKLY PATMENT AMOUNT.

    ANS :

    public class LoanCalculator

    { public double interest(double p,double t,double r){ // t is taken in years

    // r is taken as % per yearreturn p*t*r/100;

    }public double amount(double p,double t,double r){return p+interest(p,t,r);

    }

    }

    class LoanUser{

    public static void main(String ar[]){

    double p,r,t;LoanCalculator lc=new LoanCalculator();p=1500;r=12;t=2;

    println("amount of interest paid over the 2 years = "+lc.interest(p,t,r));println("total amount to be paid back = "+lc.amount(p,t,r) );println("the weekly payment amount = "+lc.amount(p,t,r)/104);

    }public static void println(String x)

    {System.out.println(x) ; }}

    QUE 10 : WAP FOR THE FOLLOWING

    # DISPLAY THE ARRAY ELEMENT

    # INSERT AN ELEMENT IN THE ARRAY

  • 8/3/2019 OOPS ALL Assignment

    16/50

    OOP SYSTEM 2010

    [SWADESH JAIN] [AB-34077] [ BATCH B-3] Page 16

    # SEARCH IN ARRAY

    # SORT THE ELEMENTS IN ASCENDING ORDER.

    ANS :

    import java.io.*;public class Array{

    int a[];int size;

    int pointer;public Array(int size){ this.size=size;

    a=new int[size];pointer=-1;

    }public boolean isEmpty(){ return pointer==-1; }

    public boolean isFull(){

    return pointer==size-1;}public void insert(int x){if(this.isFull()){

    System.out.println("can't insert. Array is full");}

    else{a[++pointer]=x;

    }

    }public void display(){for(int i=0;i

  • 8/3/2019 OOPS ALL Assignment

    17/50

    OOP SYSTEM 2010

    [SWADESH JAIN] [AB-34077] [ BATCH B-3] Page 17

    {if(x[j]>x[j+1])

    {temp=x[j+1];x[j+1]=x[j];x[j]=temp;

    }

    }}

    }}

    class MainArray{public static void main(String ar[]){

    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

    int size=0;System.out.println("enter size of array");

    try{size=Integer.parseInt(br.readLine());Array a=new Array(size);

    System.out.println("enter elements") ;for(int i=0;i

  • 8/3/2019 OOPS ALL Assignment

    18/50

    OOP SYSTEM 2010

    [SWADESH JAIN] [AB-34077] [ BATCH B-3] Page 18

    # MULTIPLICATION OF MATRIX

    # INVERSE OF MATRIX

    ANS :

    import java.io.*;public class Matrix{

    double x[][];int rows,clos;public double[][] add(double a[][],double b[][]){

    double c[][]=new double[a.length][a[0].length];for(int i=0;i

  • 8/3/2019 OOPS ALL Assignment

    19/50

  • 8/3/2019 OOPS ALL Assignment

    20/50

    OOP SYSTEM 2010

    [SWADESH JAIN] [AB-34077] [ BATCH B-3] Page 20

    QUE 12 : CREATE TWO METHODS THAT BOTH TAKE AN INT AS AN ARGUMENT

    AND RETURN A STRING OBJECT REPRESENTING THE BINARY REPRESENTATION

    OF THE INTEGER. GIVEN THE ARGUMENT 42 , IT SHOULD RETURN 101010 . THE

    FIRST METHOD SHOULD CACULATE THE BINARY REPRESENTATION

    MANUALLY, AND THE OTHER SHOULD USE THE FUNCTIONALITY AVAILABLE

    IN THE JAVA CLASS LIBRARIES.

    ANS :

    public class Binary{

    public String getBinary_Manually(int a){

    int n=a;String bin=new String();while(n>0){

    bin=""+n%2+bin;n/=2;}return bin;

    }public String getBinary_ByJava(int a){

    return Integer.toBinaryString(a) ;

    }

    }class BinaryUser{

    public static void main(String[] args) {Binary bin=new Binary();System.out.println("Manully "+bin.getBinary_Manually(42));System.out.println("Using java's method "+bin.getBinary_ByJava(42));

    }}

    QUE 13 : CREATE DIFFERENT VERSION OF A PROGRAM THAT FINDS ALL THE

    PRIMES BELOW 100. CREATE ONE VERSION THAT USES ONLY FOR LOOP. CREATE

    ANOTHER VERSION THAT ONLY USE WHILE LOOP.

    ANS :

    public class Prime {public void printPrimes(int L,int U)

    {int d;d=U-L+1;

  • 8/3/2019 OOPS ALL Assignment

    21/50

    OOP SYSTEM 2010

    [SWADESH JAIN] [AB-34077] [ BATCH B-3] Page 21

    int temp,mod,last=0,i,j,k=0;boolean flags[]=new boolean[d];

    for(int z=0;z

  • 8/3/2019 OOPS ALL Assignment

    22/50

    OOP SYSTEM 2010

    [SWADESH JAIN] [AB-34077] [ BATCH B-3] Page 22

    }}

    QUE 14 : DECLARE AN INTERFACE CALLED FUNCTION THAT HAS A METHOD

    NAMED EVALUATE THET TAKES AN INT PARAMETER AND RETURN AN INTVALUE.

    CREATE A CLASS HALF THAT IMPLEMENTS FUNCTION .MAKE THE

    IMPLETATION OF THE METHOD EVALUATE() RETURN THE VALUE OBTAINED

    BY DIVIDING THE INT ARGUMENT BY 2.

    IN CLIENT, CREATE A METHOD THAT TAKES AN ARBITRARY ARRAY OF INT

    VALUES AS PARAMETER AND RETURN AN ARRAY THAT HAS THE SAME

    LENGTH, BUT THE VALUE OF AN ELEMENT IN THE NEW ARRAY IS HALF THAT

    OF THE VALUE IN THE CORRESPONDING ELEMENT IN THE ARRAY PASSED AS

    PARAMETER. LET THE IMPLEMENTATION OF THIS METHOD CREATE AN

    INSTANCE OF HALF AND USE THIS INSTANCE TO CALCULATE THE VALUES IN

    THE ARRAY TO BE RETURNED.

    ANS :

    interface Function{

    public int evaluate(int x) ;}public class Half{public int evaluate(int x){return x/2;}

    }class ClientOfHalf{public int[] half(int [] original){

    Half h=new Half();int halfs[]=new int[original.length];for(int i=0;i

  • 8/3/2019 OOPS ALL Assignment

    23/50

    OOP SYSTEM 2010

    [SWADESH JAIN] [AB-34077] [ BATCH B-3] Page 23

    }}

    }

    QUE 15 : DESIGN A PROGRAM WHICH STARTS WITH TWO INTEGER , 0 AND 1 AND

    THEN START A FIBONACCI SEQUENCE LIKE THIS : 0,1,1,2,3,5,8,13,21,

    THE CLASS WHICH CALCULATE THIS SEQUENCE SHOULD INHERIT FROM

    THREAD CLASS. WHILE THIS CLASS IN DISPLAYING, START ANOTHER

    FIBONACCI SEQUENCE USING 2 AND 15.

    ANS :

    class Fib1 extends Thread{

    private long x[];private Fibonacci f;

    public Fib1(long a,long b, int length){

    f=new Fibonacci(a,b,length);x=new long[length];x=f.getFibs();

    }public void run()

    {System.out.print("printing f1\t");

    for(int i=1;i

  • 8/3/2019 OOPS ALL Assignment

    24/50

    OOP SYSTEM 2010

    [SWADESH JAIN] [AB-34077] [ BATCH B-3] Page 24

    {private long x[];private Fibonacci f;

    public Fib2(long a,long b,int length){

    f=new Fibonacci(a,b,length);

    x=new long[length];x=f.getFibs();

    }public void run(){ System.out.print("printing f2\t");

    for(int i=1;i

  • 8/3/2019 OOPS ALL Assignment

    25/50

    OOP SYSTEM 2010

    [SWADESH JAIN] [AB-34077] [ BATCH B-3] Page 25

    ASSIGNMENT # 4OBJECT ORIENTED PROGRAMMINGRATIONAL UNIFIED PROCESS ( RUP )A Brief history of the Rational Unified Process -The Rational Unified Process has matured over many years and reflects the

    collective experience of the many people and companies that make up Rational

    Softwares rich heritage today.

    Let us have a quick look at the processs ancestry, as illustrated in the figurebelow, "Genealogy of the Rational Unified Process".

  • 8/3/2019 OOPS ALL Assignment

    26/50

    OOP SYSTEM 2010

    [SWADESH JAIN] [AB-34077] [ BATCH B-3] Page 26

    Genealogy of the Rational Unified Process

  • 8/3/2019 OOPS ALL Assignment

    27/50

    OOP SYSTEM 2010

    [SWADESH JAIN] [AB-34077] [ BATCH B-3] Page 27

    Going backwards in time, the Rational Unified Process is the direct successor to

    the Rational Objectory Process (version 4). The Rational Unified Process

    incorporates more material in the areas of data engineering, business modeling,

    project management, and configuration management, the latter as a result of the

    merger with Pure-Atria.It also brings a tighter integration to the Rational Software

    suite of tools.

    The Rational Objectory Process was the result of the integration of the RationalApproach and the Objectory process (version 3), after the merger of Rational

    Software Corporation and Objectory AB in 1995. From its Objectory ancestry, the

    process has inherited itsprocess structure and the central concept ofuse case.

    From its Rational background, it gained the current formulation ofiterative

    developmentand architecture. This version also incorporated material on

    requirements management from Requisite, Inc. and a detailed test process inherited

  • 8/3/2019 OOPS ALL Assignment

    28/50

    OOP SYSTEM 2010

    [SWADESH JAIN] [AB-34077] [ BATCH B-3] Page 28

    fromSQA, Inc., companies which also merged with Rational Software. Finally,

    this process was the first one to use the newly created Unified Modeling Language

    (UML 0.8).

    The Objectory process was created in Sweden in 1987 by Ivar Jacobson as theresult of his experience with Ericsson. This process became a product at his

    company, Objectory AB. Centered around the concept of use case and an object-

    oriented design method, it rapidly gained recognition in the software industry and

    has been adopted and integrated by many companies worldwide. A simplified

    version of the Objectory process was published as a text book in 1992.

    The Rational Unified Process is a specific and detailed instance of a more generic

    process described by Ivar Jacobson, Grady Booch, and James Rumbaugh in the

    textbook, The Unified Software DevelopmentProcess.

    Need Of Rational Unified Process -The Rational Unified Process is a Software Engineering Process. It provides a

    disciplined approach to assigning tasks and responsibilities within a development

    organization. Its goal is to ensure the production of high-quality software that

    meets the needs of its end-users, within a predictable schedule and budget.

    The Rational Unified Process is aprocess product, developed and maintained byRational Software. The development team for the Rational Unified Process are

    working closely with customers, partners, Rational's product groups as well as

    Rational's consultant organization, to ensure that the process is continuously

    updated and improved upon to reflect recent experiences and evolving and proven

    best practices.

    The Rational Unified Process enhancesteam productivity, by providing every

    team member with easy access to a knowledge base with guidelines, templates and

    tool mentors for all critical development activities. By having all team members

    accessing the same knowledge base, no matter if you work with requirements,

    design, test, project management, or configuration management, we ensure that allteam members share a common language, process and view of how to develop

    software.

    The Rational Unified Process activities create and maintainmodels. Rather than

    focusing on the production of large amount of paper documents, the Unified

  • 8/3/2019 OOPS ALL Assignment

    29/50

    OOP SYSTEM 2010

    [SWADESH JAIN] [AB-34077] [ BATCH B-3] Page 29

    Process emphasizes the development and maintenance ofmodelssemantically

    rich representations of the software system under development.

    The Rational Unified Process is a guide for how to effectively use the Unified

    Modeling Language (UML). The UML is an industry-standard language thatallows us to clearly communicate requirements,architectures and designs. The

    UML was originally created by Rational Software, and is now maintained by the

    standards organization Object Management Group (OMG).

    The Rational Unified Process is supported bytools, which automate large parts of

    the process. They are used to create and maintain the various artifactsmodels in

    particularof the software engineering process: visual modeling, programming,testing, etc. They are invaluable in supporting all the bookkeeping associated with

    the change management as well as the configuration management that

    accompanies each iteration.

    The Rational Unified Process is aconfigurable process. No single process is

    suitable for all software development. The Unified Process fits small development

    teams as well as large development organizations. The Unified Process is founded

    on a simple and clear process architecture that provides commonality across a

    family of processes. Yet, it can be varied to accommodate different situations. It

    contains a Development Kit, providing support for configuring the process to suit

    the needs of a given organization.

    The Rational Unified Process captures many of thebest practices in modern

    software development in a form that is suitable for a wide range of projects and

    organizations. Deploying these best practices using the Rational Unified

    Process as your guide offers development teams a number of key advantages. In

    next section, we describe the six fundamental best practices of the Rational Unified

    Process.

    Effective Deployment of 6 Best Practices The Rational Unified Process describes how to effectively deploy commercially

    proven approaches to software development for software development teams.

    These are called best practices not so much because you can precisely quantifytheir value, but rather, because they are observed to be commonly used in industry

    by successful organizations. The Rational Unified Process provides each team

  • 8/3/2019 OOPS ALL Assignment

    30/50

    OOP SYSTEM 2010

    [SWADESH JAIN] [AB-34077] [ BATCH B-3] Page 30

    member with the guidelines, templates and tool mentors necessary for the entire

    team to take full advantage of among others the following best practices:

    1. Develop software iteratively

    2. Manage requirements3. Use component-based architectures Rational Unified Process: Best Practices for

    Software development Teams 2

    4. Visually model software

    5. Verify software quality

    6. Control changes to software

    Develop Software Iteratively Given todays sophisticated software systems, it is not possible to sequentiallyfirst define the entire problem, design the entire solution, build the software and

    then test the product at the end. An iterative approach is required that allows an

    increasing understanding of the problem through successive refinements, and to

    incrementally grow an effective solution over multiple iterations. The Rational

    Unified Process supports an iterative approach to development that addresses the

    highest risk items at every stage in the lifecycle, significantly reducing a projectsrisk profile. This iterative approach helps you attack risk through demonstrable

    progress frequent, executable releases that enable continuous end user involvement

    and feedback. Because each iteration ends with an executable release, the

    development team stays focused on producing results, and frequent status checkshelp ensure that the project stays on schedule. An iterative approach also makes it

    easier to accommodate tactical changes in requirements, features or schedule.

    Manage Requirements The Rational Unified Process describes how to elicit, organize, and document

    required functionality and constraints; track and document tradeoffs and decisions;

    and easily capture and communicate business requirements. The notions of use

    case and scenarios proscribed in the process has proven to be an excellent way tocapture functional requirements and to ensure that these drive the design,

    implementation and testing of software, making it more likely that the final system

    fulfills the end user needs. They provide coherent and traceable threads through

    both the development and the delivered system.

    Use Component-based Architectures

  • 8/3/2019 OOPS ALL Assignment

    31/50

    OOP SYSTEM 2010

    [SWADESH JAIN] [AB-34077] [ BATCH B-3] Page 31

    The process focuses on early development and baselining of a robustexecutable architecture, prior to committing resources for full-scale development.

    It describes how to design a resilient architecture that is flexible, accommodates

    change, is intuitively understandable, and promotes more effective software reuse.The Rational Unified Process supports component-based software development.

    Components are non-trivial modules, subsystems that fulfill a clear function. The

    Rational Unified Process provides a systematic approach to defining an

    architecture using new and existing components. These are assembled in a well-

    defined architecture, either ad hoc, or in a component infrastructure such as the

    Internet, CORBA, and COM, for which an industry of reusable components is

    emerging.

    Visually Model SoftwareThe process shows you how to visually model software to capture the structure

    and behavior of architectures and components. This allows you to hide the details

    and write code using graphicalbuilding blocks. Visual abstractions help you

    communicate different aspects of your software; see how the elements of the

    system fit together; make sure that the building blocks are consistent with your

    code; maintain consistency between a design and its implementation; and promote

    unambiguous communication. The industrystandard Unified Modeling Language

    (UML), created by Rational Software, is the foundation for successful visual

    modeling.

    Verify Software Quality Poor application performance and poor reliability are common factors whichdramatically inhibit the acceptability of todays software applications. Hence,

    quality should be reviewed with respect to the requirements based on reliability,

    functionality, application performance and system performance. The Rational

    Unified Process assists you in the planning, design, implementation, execution, and

    evaluation of these test types. Quality assessment is built into the process, in allactivities, involving all participants, using objective measurements and criteria, and

    not treated as an afterthought or a separate activity performed by a separate group.

    Control Changes to Software The ability to manage change is making certain that each change is acceptable,

  • 8/3/2019 OOPS ALL Assignment

    32/50

    OOP SYSTEM 2010

    [SWADESH JAIN] [AB-34077] [ BATCH B-3] Page 32

    and being able to track changes is essential in an environment in which change is

    inevitable. The process describes how to control, track and monitor changes to

    enable successful iterative development. It also guides you in how to establish

    secure workspaces for each developer by providing isolation from changes made in

    other workspaces and by controlling changes of all software artifacts (e.g., models,code, documents, etc.). And it brings a team together to work as a single unit by

    describing how to automate integration and build management.

    Process OverviewTwo DimensionsThe process can be described in two dimensions, or along two axis: the horizontal axis represents time and shows the dynamic aspect of the processas it is enacted, and it is

    expressed in terms of cycles, phases, iterations, and milestones. the vertical axis represents the static aspect of the process: how it is described interms of activities,

    artifacts, workers and workflows.

    The Iterative Model graph shows how the process is structured along two dimensions

  • 8/3/2019 OOPS ALL Assignment

    33/50

    OOP SYSTEM 2010

    [SWADESH JAIN] [AB-34077] [ BATCH B-3] Page 33

    Phases and Iterations - The Time DimensionThis is the dynamic organization of the process along time.

    The software lifecycle is broken into cycles, each cycle working on a new

    generation of the product. The

    Rational Unified Process divides one development cycle in four consecutivephases Inception phase Elaboration phase Construction phase Transition phaseEach phase is concluded with a well-defined milestonea point in time at whichcertain critical decisions must be

    made, and therefore key goals must have been achieved .

    Each phase has a specific purpose.

    Inception PhaseDuring the inception phase, you establish the business case for the system and

    delimit the project scope. To accomplish this you must identify all external entities

    with which the system will interact (actors) and define the nature of this interaction

    at a high-level. This involves identifying all use cases and describing a few

    significant ones. The business case includes success criteria, risk assessment, and

    estimate of the resources needed, and a phase plan showing dates of major

    milestones.

    The outcome of the inception phase is: A vision document: a general vision of the core project's requirements, keyfeatures, and main constraints. A initial use-case model (10% -20%) complete). An initial project glossary (may optionally be partially expressed as a domainmodel). An initial business case, which includes business context, success criteria(revenue projection, market recognition, and so on), and financial forecast. An initial risk assessment. A project plan, showing phases and iterations. A business model, if necessary. One or several prototypes.At the end of the inception phase is the first major project milestone: the Lifecycle

    Objectives Milestone.

    The evaluation criteria for the inception phase are:

  • 8/3/2019 OOPS ALL Assignment

    34/50

    OOP SYSTEM 2010

    [SWADESH JAIN] [AB-34077] [ BATCH B-3] Page 34

    Stakeholder concurrence on scope definition and cost/schedule estimates. Requirements understanding as evidenced by the fidelity of the primary usecases. Credibility of the cost/schedule estimates, priorities, risks, and developmentprocess. Depth and breadth of any architectural prototype that was developed. Actual expenditures versus planned expenditures.The project may be cancelled or considerably re-thought if it fails to pass this

    milestone.

    Elaboration PhaseThe purpose of the elaboration phase is to analyze the problem domain, establish a

    sound architectural foundation, develop the project plan, and eliminate the highest

    risk elements of the project. To accomplish these objectives, you must have themile wide and inch deep view of the system. Architectural decisions have to bemade with an understanding of the whole system: its scope, major functionality

    and nonfunctional requirements such as performance requirements. It is easy to

    argue that the elaboration phase is the most critical of the four phases. At the end

    of this phase, the hard engineering is considered complete and the project

    undergoes its most important day of reckoning: the decision on whether or not to

    commit to the construction and transition phases. For most projects, this also

    corresponds to the transition from a mobile, light and nimble, low-risk operation to

    a high-cost, high-risk operation with substantial inertia. While the process must

    always accommodate changes, the elaboration phase activities ensure that thearchitecture, requirements and plans are stable enough, and the risks are

    sufficiently mitigated, so you can predictably determine the cost and schedule for

    the completion of the development. Conceptually, this level of fidelity would

    correspond to the level necessary for an organization to commit to a fixed-price

    construction phase. Rational Unified Process: Best Practices for Software

    development Teams 5

    In the elaboration phase, an executable architecture prototype is built in one or

    more iterations, depending on the scope, size, risk, and novelty of the project. Thiseffort should at least address the critical use cases identified in the inception phase,

    which typically expose the major technical risks of the project. While an

    evolutionary prototype of a production-quality component is always the goal, this

    does not exclude the development of one or more exploratory, throwaway

    prototypes to mitigate specific risks such as design/requirements trade-offs,

  • 8/3/2019 OOPS ALL Assignment

    35/50

    OOP SYSTEM 2010

    [SWADESH JAIN] [AB-34077] [ BATCH B-3] Page 35

    component feasibility study, or demonstrations to investors, customers, and end-

    users.

    The outcome of the elaboration phase is: A use-case model (at least 80% complete)all use cases and actors have beenidentified, and most usecase descriptions have been developed. Supplementary requirements capturing the non functional requirements and anyrequirements that are not associated with a specific use case. A Software Architecture Description. An executable architectural prototype. A revised risk list and a revised business case. A development plan for the overall project, including the coarse-grained project

    plan, showing iterations and evaluation criteria for each iteration. An updated development case specifying the process to be used. A preliminary user manual (optional).At the end of the elaboration phase is the second important project milestone, the

    Lifecycle Architecture Milestone. At this point, you examine the detailed system

    objectives and scope, the choice of architecture, and the resolution of the major

    risks.

    The main evaluation criteria for the elaboration phase involves the answers to these

    questions: Is the vision of the product stable? Is the architecture stable? Does the executable demonstration show that the major risk elements have been

    addressed and credibly resolved? Is the plan for the construction phase sufficiently detailed and accurate? Is itbacked up with a credible basis of estimates? Do all stakeholders agree that the current vision can be achieved if the currentplan is executed to develop the complete system, in the context of the current

    architecture? Is the actual resource expenditure versus planned expenditure acceptable?The project may be aborted or considerably re-thought if it fails to pass this

    milestone. Rational Unified Process: Best Practices for Software development

    Teams 6

    Construction PhaseDuring the construction phase, all remaining components and application features

    are developed and integrated into the product, and all features are thoroughly

    tested. The construction phase is, in one sense, a manufacturing process where

  • 8/3/2019 OOPS ALL Assignment

    36/50

    OOP SYSTEM 2010

    [SWADESH JAIN] [AB-34077] [ BATCH B-3] Page 36

    emphasis is placed on managing resources and controlling operations to optimize

    costs, schedules, and quality. In this sense, the management mindset undergoes a

    transition from the development of intellectual property during inception and

    elaboration, to the development of deployable products during construction and

    transition. Many projects are large enough that parallel construction increments canbe spawned. These parallel activities can significantly accelerate the availability of

    deployable releases; they can also increase the complexity of resource management

    and workflow synchronization. A robust architecture and an understandable plan

    are highly correlated.

    In other words, one of the critical qualities of the architecture is its ease of

    construction. This is one reason why the balanced development of the architecture

    and the plan is stressed during the elaboration phase. The outcome of the

    construction phase is a product ready to put in hands of its end-users. At minimum,

    it consists of: The software product integrated on the adequate platforms. The user manuals. A description of the current release.Milestone : Initial Operational Capability

    At the end of the construction phase is the third major project milestone (Initial

    Operational Capability Milestone).

    At this point, you decide if the software, the sites, and the users are ready to go

    operational, without exposing the project to high risks. This release is often called

    a beta release.

    The evaluation criteria for the construction phase involve answering thesequestions: Is this product release stable and mature enough to be deployed in the usercommunity? Are all stakeholders ready for the transition into the user community? Are the actual resource expenditures versus planned expenditures stillacceptable?

    Transition may have to be postponed by one release if the project fails to reach this

    milestone.

    Transition PhaseThe purpose of the transition phase is to transition the software product to the user

    community. Once the product has been given to the end user, issues usually arise

    that require you to develop new releases, correct some problems, or finish the

    features that were postponed. The transition phase is entered when a baseline is

    mature enough to be deployed in the end-user domain. This typically requires that

  • 8/3/2019 OOPS ALL Assignment

    37/50

    OOP SYSTEM 2010

    [SWADESH JAIN] [AB-34077] [ BATCH B-3] Page 37

    some usable subset of the system has been completed to an acceptable level of

    quality and that user documentation is available so that the transition to the user

    will provide positive results for all parties.

    This includes:

    beta testing to validate the new system against user expectations parallel operation with a legacy system that it is replacing conversion of operational databases training of users and maintainers roll-out the product to the marketing, distribution, and sales teamsRational Unified Process: Best Practices for Software development Teams7

    The transition phase focuses on the activities required to place the software into the

    hands of the users. Typically, this phase includes several iterations, including beta

    releases, general availability releases, as well as bug-fix andenhancement releases.Considerable effort is expended in developing user-oriented documentation,

    training users, supporting users in their initial product use, and reacting to user

    feedback. At this point in the lifecycle, however, user feedback should be confined

    primarily to product tuning, configuring, installation, and usability issues.

    The primary objectives of the transition phase include: Achieving user self-supportability Achieving stakeholder concurrence that deployment baselines are complete andconsistent with the evaluation criteria of the vision Achieving final product baseline as rapidly and cost effectively as practicalThis phase can range from being very simple to extremely complex, depending on

    the type of product. For example, a new release of an existing desktop product may

    be very simple, whereas replacing a nation's air-traffic control system would be

    very complex.

    At the end of the transition phase is the fourth important project milestone, the

    Product Release Milestone.

    At this point, you decide if the objectives were met, and if you should start another

    development cycle. In some cases, this milestone may coincide with the end of theinception phase for the next cycle.

    The primary evaluation criteria for the transition phase involve the answers to

    these questions: Is the user satisfied? Are the actual resources expenditures versus planned expenditures stillacceptable?

  • 8/3/2019 OOPS ALL Assignment

    38/50

    OOP SYSTEM 2010

    [SWADESH JAIN] [AB-34077] [ BATCH B-3] Page 38

    IterationsEach phase in the Rational Unified Process can be further broken down into

    iterations. An iteration is a complete development loop resulting in a release

    (internal or external) of an executable product, a subset of the final product

    under development, which grows incrementally from iteration to iteration tobecome the final system [10].

    Benefits of an iterative approach

    Compared to the traditional waterfall process, the iterative process has the

    following advantages: Risks are mitigated earlier Change is more manageable Higher level of reuse The project team can learn along the way Better overall quality

  • 8/3/2019 OOPS ALL Assignment

    39/50

    OOP SYSTEM 2010

    [SWADESH JAIN] [AB-34077] [ BATCH B-3] Page 39

    WATERFALL Vs ITTERATIVE DEVELOPMENT

    To illustrate a problem with the waterfall model: Suppose I estimate that the

    project will take two years, and it really takes three years. At the end of twoyears, what do I have? Nothing useful works. No partial delivery is possible.Diagrams and models are great, but they can not execute.

    Waterfall is conceptually straightforward because it produces a singledeliverable for each step (requirements, analysis model, design model,code, etc), resulting in a single release. The fundamental problem is that itpushes risk forward in time, where its costly to undo mistakes from earlierphases. An initial design will likely be flawed with respect to its keyrequirements, and furthermore, the late discovery of design defects tendsto result in costly overruns or project cancellation. The waterfall approachtends to mask the real risks to a project until it is too late to do anythingmeaningful about them.

  • 8/3/2019 OOPS ALL Assignment

    40/50

  • 8/3/2019 OOPS ALL Assignment

    41/50

    OOP SYSTEM 2010

    [SWADESH JAIN] [AB-34077] [ BATCH B-3] Page 41

    The earliest iterations address greatest risks. Each iteration produces anexecutable release. Each iteration includes integration and test. Iterationshelp: resolve major risks before making large investments.

    enable early user feedback. make testing and integration continuous. focus project short-term objective milestones. make possible deployment of partial implementations.

    Iterative development produces the architecture first, allowing integration tooccur as the verificationactivity of the design phase and allowing designflaws to be detected and resolved earlier in the lifecycle. Continuousintegration throughout the project replaces the big bang integration at theend of a project. Iterative development also provides much better insightinto quality, because of system characteristics that are largely inherent in

  • 8/3/2019 OOPS ALL Assignment

    42/50

    OOP SYSTEM 2010

    [SWADESH JAIN] [AB-34077] [ BATCH B-3] Page 42

    the architecture. For example, performance, fault tolerance, andmaintainability are tangible earlier in the process. Thus, issues are stillcorrectable without jeopardizing target costs and schedules.

  • 8/3/2019 OOPS ALL Assignment

    43/50

    OOP SYSTEM 2010

    [SWADESH JAIN] [AB-34077] [ BATCH B-3] Page 43

    ASSIGNMENT # 5OBJECT ORIENTED PROGRAMMINGSYSTEMWRITE COMPLETE JAVA APPLICATION DEPECTING FOLLOWING CONCEPTS

    # INHERITANCE

    class A{

    int a;public void showA(){

    System.out.println("a= "+a);}public void setA(int n){

    a=n;}

    }class B extends A{

    int b;public void showB(){

    System.out.println("b= "+b);}public void setB(int n)

    {b=n;

    }

    }class C extends B{

    int c;public void showC(){

    System.out.println("c= "+c);}public void setC(int n)

    {c=n;

    }

    }class InheritanceDemoMain{

    public static void main(String[] args) {A a=new A();B b=new B();C c=new C();

  • 8/3/2019 OOPS ALL Assignment

    44/50

    OOP SYSTEM 2010

    [SWADESH JAIN] [AB-34077] [ BATCH B-3] Page 44

    System.out.println("by class A ......");a.setA(5);a.showA();System.out.println("by class B ......");b.setA(25);b.setB(6);

    b.showA();b.showB();System.out.println("by class C ......");c.setA(125);c.setB(36);c.setC(7);c.showA();c.showB();c.showC();

    }}# POLYMORPHISM

    import java.io.*;class Parallelogram{

    public double area(double a,double b,double angle){

    return Math.abs(a*b*Math.sin(angle));}public double area(double a,double b){ System.out.println("computing area of parallelogram..........");

    return a*b;}

    }

    class Rectangle extends Parallelogram{

    public double area(double a,double b){

    System.out.println("computing area of Rectangle..........");return a*b;

    }

    }

    class Demo{

    public static void main(String[] args) {Parallelogram p=new Parallelogram();Rectangle r=new Rectangle();System.out.println("area of parallelogram with its two adjecent sides and angle between them is given....

    \n"+p.area(10,20,0.5));System.out.println("area of parallelogram with its height and width given......\n"+p.area(10, 20));System.out.println("area of Rectangle with its height and width given......\n"+r.area(10, 20));

  • 8/3/2019 OOPS ALL Assignment

    45/50

  • 8/3/2019 OOPS ALL Assignment

    46/50

    OOP SYSTEM 2010

    [SWADESH JAIN] [AB-34077] [ BATCH B-3] Page 46

    {a=5;

    System.out.println("inside static block");System.out.println(a*a);System.out.println("outside static block");

    }

    public static int square(int x){return x*x;

    }

    }class StaticDemoMain{

    public static void main(String[] args){System.out.println("a= "+StaticDemo.a) ;new StaticDemo();

    System.out.println("number of object created = "+StaticDemo.count);new StaticDemo();new StaticDemo();System.out.println("number of object created = "+StaticDemo.count);System.out.println("square of 6 = "+StaticDemo.square(6));

    }}

    # CONSTRUCTOR

    class A{ int a,b;

    public A(){ System.out.println("inside zero parameter construtor of A");

    a=0;b=0;

    }public A(int i){

    this(i,i);System.out.println("inside one parameter construtor of A");

    }public A(int i,int j)

    { this();a=i;b=i*j;System.out.println("inside two parameter construtor of A");

    }

    public void showA(){

    System.out.println("a= "+a);

  • 8/3/2019 OOPS ALL Assignment

    47/50

    OOP SYSTEM 2010

    [SWADESH JAIN] [AB-34077] [ BATCH B-3] Page 47

    }public void showB(){

    System.out.println("b= "+b);}

    }

    class C extends A{ int c;

    public C(){

    super();System.out.println("inside zero parameter construtor of C");c=0;

    }public C(int i,int j,int k){

    super(i,j);c=i*j*k;System.out.println("inside three parameter construtor of C");

    }public C(int i){

    super(i);c=i*i*i;System.out.println("inside two parameter construtor of C");

    }public void showC()

    {System.out.println("c= "+c);

    }}

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

    C c=new C(1,2,3);c.showA();c.showB();c.showC();

    }}

    # EXCEPTION HANDELING

    class DivideByZeroException extends Exception{

    public String toString(){

    return "DivideByZeroException";}

  • 8/3/2019 OOPS ALL Assignment

    48/50

    OOP SYSTEM 2010

    [SWADESH JAIN] [AB-34077] [ BATCH B-3] Page 48

    public DivideByZeroException(){

    System.out.println("DivideByZeroException thrown........");}

    }class Division{

    public int divide(int a,int b) throws DivideByZeroException{

    if(b==0)throw new DivideByZeroException();

    elsereturn a/b;

    }

    }class ExceptionDemo{

    public static void main(String a[]){

    try{

    Division d=new Division() ;d.divide(5, 0);

    }catch(DivideByZeroException e){

    System.out.println(e.toString());

    }finally{

    System.out.println("closing the program............");System.exit(0);

    }}

    }

    # ABSTRACT CLASS

    import java.util.*;abstract class Stack{

    protected ArrayList stack;protected int top=-1;public abstract void push(T t);public abstract T pop();public boolean isEmpty(){

  • 8/3/2019 OOPS ALL Assignment

    49/50

    OOP SYSTEM 2010

    [SWADESH JAIN] [AB-34077] [ BATCH B-3] Page 49

    if(top==-1)return true;

    elsereturn false;

    }public T peek()

    { if(!isEmpty())return stack.get(top) ;

    else return null;}

    }class MyStack extends Stack

    {MyStack(){

    stack=new ArrayList();}

    public void push(T t){

    top++;

    stack.add(top, t);}public T pop(){ if(!isEmpty())

    {T t= stack.get(top) ;

    stack.remove(top) ;--top;return t;}

    elsereturn null;}

    }class UseStack{

    public static void main(String[] args) {Stack stack=new MyStack();String s="SWADESH";for(int i=0;i

  • 8/3/2019 OOPS ALL Assignment

    50/50

    OOP SYSTEM 2010

    }

    # INTERFACES

    interface Bouncable{

    public static final boolean bounces=true;public static final boolean isRound=true;public void bounce();

    }class FootBall implements Bouncable{

    public void bounce(){

    System.out.println("bouncing in football ground.......");}

    }class BasketBall implements Bouncable{

    public void bounce(){

    System.out.println("bouncing in basketball court.......");}

    }class MainInterface{

    public static void main(String[] args) {FootBall fb=new FootBall();

    BasketBall bb=new BasketBall();fb.bounce();bb.bounce();

    }}