-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathBox.java
More file actions
41 lines (31 loc) · 752 Bytes
/
Box.java
File metadata and controls
41 lines (31 loc) · 752 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
41
package chapter6;
public class Box {
double width;
double height;
double depth;
Box() {
System.out.println("Constructing Box");
width = 10;
height = 10;
depth = 10;
}
Box(double width, double height, double depth) {
System.out.println("Constructing Box");
this.width = width;
this.height = height;
this.depth = depth;
}
//display volume of a box
void volume() {
System.out.print("Volume is ");
System.out.println(width * height * depth);
}
double volume2() {
return width * height * depth;
}
void setDim(double w, double h, double d) {
width = w;
height = h;
depth = d;
}
}