-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPoint.java
More file actions
49 lines (40 loc) · 944 Bytes
/
Point.java
File metadata and controls
49 lines (40 loc) · 944 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
public class Point extends Shape {
private double x;
private double y;
// create constructers
// empty
public Point() {
x = 0;
y = 0;
}
// with params
public Point(double x, double y) {
this.x = x;
this.y = y;
}
public void setX(double xCoord) {
x = xCoord;
}
public double getX() {
return x;
}
public void setY(double yCoord) {
y = yCoord;
}
public double getY() {
return y;
}
// set location
public void setLocation(double x, double y) {
setX(x);
setY(y);
}
// set Distance
public double distance(double x, double y) {
return Math.sqrt(Math.pow(x - this.x, 2) + Math.pow(y - this.y, 2));
}
// toString()
public String toString() {
return "Point (" + this.x + ", " + this.y + ")";
}
}