-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMyCircle.java
More file actions
44 lines (33 loc) · 781 Bytes
/
Copy pathMyCircle.java
File metadata and controls
44 lines (33 loc) · 781 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
public class MyCircle {
private double x;
private double y;
private double radius;
public void setX(double xCoordinate) {
x = xCoordinate;
}
public double getX() {
return x;
}
public void setY(double yCoordinate) {
y = yCoordinate;
}
public double getY() {
return y;
}
public void setRadius(double r) {
radius = r;
}
public double getRadius() {
return radius;
}
public double getArea() {
return (Math.PI * Math.pow(radius, 2));
}
public boolean doesOverlap(MyCircle otherCircle) {
double sum, distance;
sum = radius + otherCircle.getRadius();
distance = Math.sqrt((x - otherCircle.getX()) * (x - otherCircle.getX()) + (y - otherCircle.getY()) * (y - otherCircle.getY()));
if (sum > distance) return true;
else return false;
}
}