-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMultiLevelDemo.java
More file actions
79 lines (79 loc) · 1.63 KB
/
MultiLevelDemo.java
File metadata and controls
79 lines (79 loc) · 1.63 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
class HBox{
private double width;
private double height;
private double depth;
HBox(HBox obj){
width = obj.width;
height = obj.height;
depth = obj.depth;
}
HBox(double w,double h,double d){
width = w;
height = h;
depth = d;
}
HBox(){
width = height = depth = -1;
}
HBox(double len){
width = height = depth = len;
}
double volume(){
return width*height*depth;
}
}
class HBoxWeight extends HBox{
double weight;
HBoxWeight(HBoxWeight obj){
super(obj);
weight = obj.weight;
}
HBoxWeight(HBox obj,double m){
super(obj);
weight = m;
}
HBoxWeight(double w,double h,double d,double m){
super(w,h,d);
weight = m;
}
HBoxWeight(){
super();
weight = -1;
}
HBoxWeight(double len,double weight){
super(len);
this.weight=weight;
}
}
class ShipmentHBox extends HBoxWeight{
double cost;
ShipmentHBox(ShipmentHBox obj){
super(obj);
cost = obj.cost;
}
ShipmentHBox(double w,double h,double d,double m,double c){
super(w,h,d,m);
cost = c;
}
ShipmentHBox(){
super();
cost = -1;
}
ShipmentHBox(double len,double m,double c){
super(len,m);
cost = c;
}
}
public class MultiLevelDemo {
public static void main(String args[]){
ShipmentHBox obj1 = new ShipmentHBox(10,20,15,10,3.41);
ShipmentHBox obj2 = new ShipmentHBox(2,3,4,0.76,1.28);
System.out.println("Volume of obj1 is:"+obj1.volume());
System.out.println("Weight of obj1 is:"+obj1.weight);
System.out.println("Cost of obj1 is:$"+obj1.cost);
System.out.println();
System.out.println("Volume of obj2 is:"+obj2.volume());
System.out.println("Weight of obj2 is:"+obj2.weight);
System.out.println("Cost of obj2 is:$"+obj2.cost);
}
}