blob: 45aa4e337fd59b56fb602fd67a6c609ae7ac5243 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
public class MyCircle implements Shape2d {
private MyPoint center;
private double r;
/**
* Creates a 2d circle object
*
* @param center Center of the circle
* @param r Radius of the circle
*/
public MyCircle(MyPoint center, double r) {
this.center = center;
this.r = Math.abs(r);
}
public double area() {
return Math.PI * this.r * this.r;
}
public double perimeter() {
return 2 * this.r * Math.PI;
}
}
|