-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathCylinder.java
More file actions
39 lines (29 loc) · 728 Bytes
/
Cylinder.java
File metadata and controls
39 lines (29 loc) · 728 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
package src;
public class Cylinder extends Circle {
private double height = 1.0;
public Cylinder() {
super();
}
public Cylinder(double radius) {
super(radius);
}
public Cylinder(double radius, double height) {
this(radius);
this.height = height;
}
public double getHeight() {
return this.height;
}
public double getVolume() {
return super.getArea()*height;
}
@Override
public double getArea() {
return 2*Math.PI*getRadius()*height + 2* super.getArea();
}
@Override
public String toString() {
return "Cylinder: subclass of " + super.toString()
+ " height=" + height;
}
}