-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInterfaceArea.java
More file actions
57 lines (45 loc) · 1.17 KB
/
InterfaceArea.java
File metadata and controls
57 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
51
52
53
54
55
56
57
public interface InterfaceArea {
double pi = 3.1456;
double area();
double perimeter();
}
interface volume extends InterfaceArea{
double volume();
}
class Circle123 implements InterfaceArea{
private double radius;
Circle123(double radius){
this.radius = radius;
}
public double area(){
return pi*radius*radius;
}
public double perimeter(){
return 2*pi*radius;
}
class Box implements volume{
private double length,breadth,height;
Box(double l ,double b, double h){
this.length = l;
this.breadth = b;
this.height = h;
}
@Override
public double area() {
return 2*(length*breadth+breadth*height+height*length);
}
@Override
public double perimeter() {
return 0;
}
@Override
public double volume() {
return length*breadth*height;
}
}
public static void main(String[] args) {
InterfaceArea interfaceArea = new Circle123(4.55);
System.out.println(interfaceArea.area());
System.out.println(interfaceArea.perimeter());
}
}