Viewing code of sirish
// ------ ../cgi-bin/java/sirish.java --------------
//--- Programmed By Rajesh -----
import java.math.*;
class Point{
float x;
float y;
Point(){
x=0;
y=0;
}
Point(float x,float y){
this.x=x;
this.y=y;
}
Point(Point p){
x=p.x;
y=p.y;
}
boolean equal (Point p){
return ((x==p.x)&&(y==p.y));
}
}
class line{
Point p1;
Point p2;
line (Point p1,Point p2){
this.p1=p1;
this.p2=p2;
}
line (){
p1= new Point();
p2= new Point();
}
line (line l){
this.p1=l.p1;
this.p2=l.p2;
}
boolean equal(line l){
return (p1==l.p1)&&(p2==l.p2);
}
double distance(){
double a=p1.x-p2.x;
double b=p1.y-p2.y;
double c=Math.pow(a,2)+Math.pow(b,2);
double d=Math.sqrt(c);
return d;
}
}
class PointandLine{
public static void main(String args[]){
Point p1=new Point();
Point p2=new Point(2,3);
Point p3=new Point(p2);
line l1=new line(new Point(2,2),new Point(3,3));
line l2=new line(p1,p2);
System.out.println("p1(x)= "+p1.x +" p1(y)= "+p1.y);
System.out.println("p2(x)= "+p2.x +" p2(y)= "+p2.y);
System.out.println("p3(x)= "+p3.x +" p3(y)= "+p3.y);
System.out.println("p1 equals p2:"+p1.equal(p2));
System.out.println("p2 equals p3:"+p2.equal(p3));
System.out.println("------------------------------");
System.out.println("l1:");
System.out.println(" Points(I): ("+l1.p1.x+","+l1.p1.y+")");
System.out.println(" Points(II): ("+l1.p2.x+","+l1.p2.y+")");
System.out.println("l2:");
System.out.println(" Points(I): ("+l2.p1.x+","+l2.p1.y+")");
System.out.println(" Points(II): ("+l2.p2.x+","+l2.p2.y+")");
System.out.println("l1 equals l2:"+l1.equal(l2));
System.out.println("The distance between 2 points in line 1 is:"+l1.distance());
}
}
Home
Library Home:
- 1 Addition
- 2 BoxUser
- 3 BoxUser1
- 4 BoxUser2
- 5 Calc
- 6 Check
- 7 Circle
- 8 point
- 9 CircleMain
- 10 Clock
- 11 Compare
- 12 Constant
- 13 raan
- 14 CurentThreadDemo
- 15 sidd
- 16 CurrentThread
- 17 multi
- 18 CurrentThreadDemo
- 19 Driver
- 20 Fact
- 21 sirish
- 22 Factorial
- 23 Factorlial
- 24 FrameAndMenu
- 25 GF
- 26 GUI
- 27 GUITest
- 28 GrandFather
- 29 HariNarayanDemo
- 30 HariNarayanDemor
- 31 HariNayaranDemo
- 32 HariNayaranDemoR
- 33 HelloKU
- 34 HelloUser2
- 35 HelloWorld
- 36 HelloWorld2
- 37 Line
- 38 Line1
- 39 Main
- 40 MainCircle
- 41 MethodsTest
- 42 MyName
- 43 MyName1
- 44 ObjCreator
- 45 Recursion
- 46 Sort
- 47 multi1
- 48 StupidThreadDemoE
- 49 StupiedThread
- 50 StupiedThreadDemo
- 51 notepad
- 52 StupiedThreadDemoE
- 53 Swap
- 54 Symphony
- 55 anABC
- 56 calulation
- 57 creation
- 58 jframe
- 59 modifiedJFrame