-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBoxFigure.java
More file actions
50 lines (42 loc) · 1.16 KB
/
BoxFigure.java
File metadata and controls
50 lines (42 loc) · 1.16 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
package unit_07.Examples.Example_07;
public class BoxFigure extends RectangleFigure {
private double height;
public BoxFigure() {
super();
height = 0;
}
public BoxFigure(double length, double width, double height) {
super(length, width);
if (height >= 0) {
this.height = height;
} else {
height = 0;
}
}
public void setDimension(double length, double width, double height) {
super.setDimension(length, width);
if (height >= 0) {
this.height = height;
} else {
height = 0;
}
}
public double getHeight() {
return height;
}
public double area() {
return 2 * (getLength() * getWidth() +
getLength() * height +
getWidth() * height);
}
public double volume() {
return (super.area() * height);
}
public String toString() {
return ("Length = " + getLength() +
" Width = " + getWidth() +
" Height = " + height +
" Surface area = " + area() +
" Volume = " + volume());
}
}