-
Notifications
You must be signed in to change notification settings - Fork 138
/
Solution.cpp
61 lines (57 loc) · 1.14 KB
/
Solution.cpp
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
//Implement the class Box
//l,b,h are integers representing the dimensions of the box
// The class should have the following functions :
// Constructors:
// Box();
// Box(int,int,int);
// Box(Box);
class Box {
private:
int length, breadth, height;
public:
Box() {
length = 0;
breadth = 0;
height = 0;
}
Box(int l, int b, int h) {
length = l;
breadth = b;
height = h;
}
Box(const Box &B) {
length = B.length;
breadth = B.breadth;
height = B.height;
}
int getLength() {
return length;
}
int getBreadth() {
return breadth;
}
int getHeight() {
return height;
}
long long CalculateVolume() {
return (long long)(breadth) * length * height;
}
bool operator<(Box &B) {
if (length < B.length) {
return true;
} else if (length == B.length) {
if (breadth < B.breadth) {
return true;
} else if (breadth == B.breadth) {
if (height < B.height) {
return true;
}
}
}
return false;
}
};
ostream &operator<<(ostream &out, Box &B) {
out << B.getLength() << " " << B.getBreadth() << " " << B.getHeight();
return out;
};