-
Notifications
You must be signed in to change notification settings - Fork 0
/
Point.java
29 lines (28 loc) · 663 Bytes
/
Point.java
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
public class Point{
private double x;
private double y;
public Point(double a, double b) {
x = a;
y = b;
}
public Point(Point a){
x = a.x;
y = a.y;
}
public double getX(){
return x;
}
public double getY(){
return y;
}
public static double distance(Point a, Point b){
System.out.println((Math.pow((a.y - b.y), 2)));
return (Math.sqrt(Math.abs(Math.pow((a.x - b.x), 2)- (Math.pow((a.y - b.y), 2)))));
}
public double distanceTo(Point a){
return (Math.sqrt(Math.abs(Math.pow((this.x - a.x), 2)- (Math.pow((this.y - a.y), 2)))));
}
public String toString(){
return"(" + x + "," + y+ ")";
}
}