You are on page 1of 5

Assignment #2

-----------------------------------------------------------------
Object oriented programming using java.
Submitted By:
Name: PirZada.
Submitted To:
Name: Pro. Dr. Muhammad Shiraz.
Section : BS(CS)2 nd D
Submission Date: Monday, 7, July 2020.
class Example
{
int x,y,z;
Example(int a ,int b,int c)
{
x=a; y=b; z=c;
}
//Example add
{
Example temp=new Example (0,0,0);
temp.x=x+ob.x;
temp.y=x+ob.y;
temp.z=x+ob.z;
return temp;
}
//Example sub
{
Example temp=new Example(0,0,0);
temp.x=x-ob.x;
temp.y=x-ob.y;
temp.z=x-ob.z;
return temp;
}
// Example mul
{
Example temp=new Example(0,0,0);
temp.x=x*ob.x; temp.y=x*ob.y;
temp.z=x*ob.z; return temp;
}
void get()
{
System.out.println("x="+x);
System.out.println("y="+y);
System.out.println("Z="+z);
}
}
class practicle
{
public static void main(String[] args)
{
Example ob1=new Example(10,15,20);
Example ob2=new Example(10,20,35);
Example ob3;
Example ob4;
Example ob5; ob5=ob1.add(ob2);
ob4=ob1.sub(ob2);
ob3=ob1.mul(ob2);
ob1.get();
ob2.get();
ob3.get();
ob4.get();
ob5.get();
}
}
_________________________________________

You might also like