-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathPoint_Test.java
More file actions
62 lines (54 loc) · 1.28 KB
/
Point_Test.java
File metadata and controls
62 lines (54 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//By KHUHSAL AGARWAL
class Point {
private double x;
private double y;
public void setX(double x) {
this.x = x;
}
public void setY(double y) {
this.y = y;
}
public double getX() {
return x;
}
public double getY() {
return y;
}
void equality(Point p1,Point p2)
{
if(p1.x==p2.x && p1.y==p2.y)
{
System.out.println("Equal Points.");
}
else
{
System.out.println("Not Equal Points.");
}
}
double distance(Point p1,Point p2)
{
double dis=Math.sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p2.y-p1.y)*(p2.y-p1.y));
return dis;
}
void display(Point p1,Point p2)
{
System.out.println("Point 1 :- ");
System.out.println("x= "+p1.getX()+" y= "+p1.getY());
System.out.println("Point 2 :- ");
System.out.println("x= "+p2.getX()+" y= "+p2.getY());
p1.equality(p1,p2);
System.out.println(p1.distance(p1,p2));
}
}
class pointTest {
public static void main(String[] args) {
Point p1=new Point();
p1.setX(3.4);
p1.setY(5.6);
Point p2=new Point();
p2.setX(13.4);
p2.setY(15.6);
p1.display(p1,p2);
p2.distance(p1,p2);
}
}