-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoop23.java
58 lines (43 loc) · 1.05 KB
/
oop23.java
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
51
52
53
54
55
56
57
58
interface Paramerter{
void Rectangle();
void Square();
void Sphere();
void Circle();
}
class Shape implements Paramerter{
public int l,b,h;
Shape(int l,int b,int h){
this.l=l;
this.b=b;
this.h=h;
}
@Override
public void Rectangle(){
System.out.println("Area = "+ l*b);
System.out.println("Volume = " +l*b*h);
}
@Override
public void Square(){
System.out.println("Area = "+ l*b);
System.out.println("Volume = " +l*b*h);
}
@Override
public void Circle(){
System.out.println("Area = "+ l*l);
System.out.println("Volume = " +l*l*l);
}
@Override
public void Sphere() {
System.out.println("Area = "+4*Math.PI*l*l);
System.out.println("Volume = " +(4*Math.PI*l*l*l)/3);
}
}
public class oop23 {
public static void main(String[] args) {
Shape shape=new Shape(5,6,7);
shape.Rectangle();
shape.Square();
shape.Circle();
shape.Sphere();
}
}