-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathTestCylinder.java
More file actions
33 lines (29 loc) · 1.24 KB
/
TestCylinder.java
File metadata and controls
33 lines (29 loc) · 1.24 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
package src;
public class TestCylinder {
public static void main (String[] args) {
// Declare and allocate a new instance of cylinder
// with default color, radius, and height
Cylinder c1 = new Cylinder();
System.out.println("Cylinder:"
+ " radius=" + c1.getRadius()
+ " height=" + c1.getHeight()
+ " base area=" + ((Circle) c1).getArea()
+ " volume=" + c1.getVolume());
// Declare and allocate a new instance of cylinder
// specifying height, with default color and radius
Cylinder c2 = new Cylinder(10.0);
System.out.println("Cylinder:"
+ " radius=" + c2.getRadius()
+ " height=" + c2.getHeight()
+ " base area=" + ((Circle) c2).getArea()
+ " volume=" + c2.getVolume());
// Declare and allocate a new instance of cylinder
// specifying radius and height, with default color
Cylinder c3 = new Cylinder(2.0, 10.0);
System.out.println("Cylinder:"
+ " radius=" + c3.getRadius()
+ " height=" + c3.getHeight()
+ " base area=" + ((Circle) c3).getArea()
+ " volume=" + c3.getVolume());
}
}