-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPoint.java
More file actions
57 lines (40 loc) · 1.03 KB
/
Copy pathPoint.java
File metadata and controls
57 lines (40 loc) · 1.03 KB
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
50
51
52
53
54
55
56
57
package two;
/**
*
* @author Student
*/
public class Point {
int x;
int y;
public Point(int x, int y) {
this.x = x;
this.y = y;
}
@Override
public String toString() {
return "Point{" + "x=" + x + ", y=" + y + '}';
}
}
class Circle extends Point{
double radius;
public Circle(int x, int y, double radius) {
super(x, y);
this.radius = radius;
}
public double getArea(){
return (3.1416)*radius*radius;
}
public double getCircumference(){
return 2 * (3.1416) * radius;
}
@Override
public String toString() {
return "Circle[center=("+x +"," + y+");" + "radius=" + radius + ']';
}
public static void main(String[] args) {
Circle c1 = new Circle(75, 20, 70);
System.out.println(c1);
System.out.println("Area of the Circle 1: "+ c1.getArea());
System.out.println("Circumference of the Circle 1: "+ c1.getCircumference());
}
}