forked from mpmenne/launchcode-java-class
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCircle.java
More file actions
49 lines (35 loc) · 932 Bytes
/
Copy pathCircle.java
File metadata and controls
49 lines (35 loc) · 932 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
import java.io.File;
/**
* Created by dshook on 5/6/15.
*/
public class Circle implements Measurable{
private double radius;
public Circle() {
this.radius = 10.0;
}
public void setRadius(double r) {
}
public Circle(double r) {
if (r < 0) {
throw new IllegalArgumentException();
}
this.radius = r;
}
public static double getArea(double r) {
return Math.PI * r * r;
}
@Override
public double getArea() {
return Math.PI * this.radius * this.radius;
}
@Override
public double getPerimeter() {
return 2 * Math.PI * this.radius;
}
public static void main(String[] args) {
Measurable circle = MeasurableFactory.getShape(1);
System.out.println(circle.getArea());
Measurable square = MeasurableFactory.getShape(4);
System.out.println(square.getArea());
}
}