-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCylinder.java
More file actions
44 lines (32 loc) · 1007 Bytes
/
Copy pathCylinder.java
File metadata and controls
44 lines (32 loc) · 1007 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
package javapro;
class Cylinder extends ThreeDShape{
static final String CLASS_NAME = "Cylinder"; //This Class name is Cylinder
Circle circle1;//composition
public Cylinder(String name, double rad, double height) {
super(name,rad,rad,height);//I need radius and height to calculate the volume of Cylinder
circle1 = new Circle(name, rad); }
public String getClassName() {
return CLASS_NAME;
}
public double getRadious() {
return super.getDimension1();
}
public void setRadious(double rad) {
super.setDimension1(rad);
super.setDimension2(rad);
}
public double getHeight() {
return super.getDimension3();
}
public void setHeight(double Height) {
super.setDimension3(Height);
//get + set methods
}
public double getVolume() {
return Math.PI* super.getDimension1()*super.getDimension2()*super.getDimension3();
}
public String toString() {
return String.format("%s is a [%s], and is a [%s]",
super.getName(), getClassName(), super.getClassName());
}
}