-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLab_Question.java
More file actions
51 lines (32 loc) · 1.33 KB
/
Lab_Question.java
File metadata and controls
51 lines (32 loc) · 1.33 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
public class Lab_Question {
public static void main(String[] args) {
Square s1 = new Square(10);
Square s2 = new Square(11);
Rectangle r1 = new Rectangle(5,10);
Circle c1 = new Circle(6);
Sphere sp1 = new Sphere(5,10);
Cylinder cy1 = new Cylinder(10,6);
compareArea(c1,s1);
compareArea(r1,s1);
compareArea(sp1,s1);
compareVolume(cy1,cy1);
}
public static void compareVolume(Shape3D s1, Shape3D s2){
if(s1.getVolume() > s2.getVolume()){
System.out.println("First Volume is greater than second Volume. Bigger Volume :" +s1.getArea());
} else if(s1.getVolume() == s2.getVolume()){
System.out.println("Volume values are equals");
}else {
System.out.println("Second Volume is greater than first Volume. Bigger Volume :" +s2.getArea());
}
}
public static void compareArea(Shape2D s1, Shape2D s2){
if(s1.getArea() > s2.getArea()){
System.out.println("First area is greater than second area. Bigger area :" +s1.getArea());
} else if(s1.getArea() == s2.getArea()){
System.out.println("Area values are equals");
}else {
System.out.println("Second area is greater than first area. Bigger area :" +s2.getArea());
}
}
}