-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpoint.java
More file actions
32 lines (26 loc) · 746 Bytes
/
point.java
File metadata and controls
32 lines (26 loc) · 746 Bytes
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
// class point for the declaring the two point object
public class point{
private int x;
private int y;
public point(int a, int b)
{
x= a;
y= b;
}
public int getx(){return x;}
public int gety(){return y;}
//calculate the distance
public double distance(point other)
{
int dx=x-other.getx();
int dy=y-other.gety();
return Math.sqrt(dx*dx+dy*dy);
}
// main program
public static void main(String[] args){
//two object for defining path and points are co-ordinates
point p1= new point(3,9);
point p2= new point(5,5);
System.out.println(p1.distance(p2));
}
}