-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBox.java
More file actions
40 lines (32 loc) · 830 Bytes
/
Box.java
File metadata and controls
40 lines (32 loc) · 830 Bytes
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
package unit_07.Examples.Example_01;
public class Box extends Rectangle {
private double height;
public Box() {
super();
height = 0;
}
public Box(double l, double w, double h) {
super(l, w);
height = h;
}
public void setDimension(double l, double w, double h) {
super.setDeimension(l, w);
if (h >= 0) {
height = h;
} else {
height = 0;
}
}
public double getHeight() {
return height;
}
public double area() {
return 2 * (getLength() * getHeight() + getLength() * getWidth() + getWidth() * getHeight());
}
public double volume() {
return super.area() * getHeight();
}
public String toStr() {
return (super.toStr() + "; Height = " + height);
}
}