-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPractice10_Inharitance.java
More file actions
86 lines (67 loc) · 1.32 KB
/
Practice10_Inharitance.java
File metadata and controls
86 lines (67 loc) · 1.32 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package com.company;
//1. & 3.
//class circle{
// double radius;
//
// circle (int r){
// this.radius = r;
// }
//
// double area (){
// double a = 3.14 * radius * radius;
// return a;
// }
//}
//class cylinder extends circle{
// double height;
//
// cylinder(int r, int h){
// super(r);
// this.height = h;
// }
//
// double vol(){
// double a = 3.14 * height * 2 * radius;
// return a;
// }
//}
//2. & 4.
class rectangle{
public int height;
public int breath;
rectangle (int h, int b){
this.breath = b;
this.height = h;
}
int area(){
int a = height * breath;
return a;
}
}
class cuboid extends rectangle{
public int width;
public int getWidth() {
return width;
}
public void setWidth(int width) {
this.width = width;
}
cuboid (int h, int b, int w){
super(h,b);
this.width = w;
}
int vol(){
int a = height*width*breath;
return a;
}
}
public class Practice10_Inharitance {
public static void main(String[] args) {
// 1. & 3.
// circle c = new circle(6);
// System.out.println(c.area());
// cylinder r = new cylinder(5,3);
// System.out.println(r.vol());
// 2.& 4.
}
}