-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBox.java
More file actions
48 lines (45 loc) · 1.09 KB
/
Box.java
File metadata and controls
48 lines (45 loc) · 1.09 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
public class Box {
double l;
double h;
double w;
double b;
// double f;
// double a;
// double b;
// double weight;
// static void greeting() {
// System.out.println("Hey, I am in Box class. Greetings!");
// }
// public double getL() {
// return l;
// }
Box (double s) {
// super(); Object class
System.out.println("Single Parameterized Constructor");
this.w = s;
this.l = s;
this.h = s;
}
// Default Constructor -> same name as of the class name
// No Parameterized Constructor
Box () {
System.out.println("Default Constructor");
this.h = -1;
this.l = -1;
this.w = -1;
}
// cube
// Parametrized Constructor
Box(double l, double h, double w) {
System.out.println("Box class constructor");
this.l = l;
this.h = h;
this.w = w;
}
// Copying Constructor
Box(Box other) {
this.h = other.h;
this.l = other.l;
this.w = other.w;
}
}