-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCylinder.java
More file actions
50 lines (45 loc) · 1.17 KB
/
Cylinder.java
File metadata and controls
50 lines (45 loc) · 1.17 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
public class Cylinder extends Shape3D{
private int radius;
private int height;
public Cylinder(){
super();
radius = 0;
}
public Cylinder(int radius, int height){
this. radius = radius;
this.height = height;
super(height, radius*2, radius*2);
}
public double getSurfaceArea(){
return (2*Math.PI*radius*height) + (2*Math.PI*radius*radius);
}
public int getRadius(){
return radius;
}
public int getHeight(){
return height;
}
@Override
public int getDepth(){
return radius*2;
}
@Override
public int getWidth(){
return radius*2;
}
public void setRadius(int radius){
this.radius = radius;
}
public void setHeight(int height){
this.height = height;
}
// setting the depth and width with parameters could lead to inconsistencies with the radius
@Override
public int setDepth(){
this.depth = radius*2;
}
@Override
public void setWidth(){
this.width = radius*2;
}
}