-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBoxIt.cpp
44 lines (38 loc) · 953 Bytes
/
BoxIt.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
#include <iostream>
// problem : https://www.hackerrank.com/challenges/box-it/problem
// soultion ========================================================================
class Box {
private:
int l = 0, b = 0, h = 0;
public:
Box() {
}
Box(int length, int breadth, int height) :l(length), b(breadth), h(height) {
}
Box(const Box& B) {
l = B.l, b = B.b, h = B.h;
}
int getLenght() {
return l;
}
int getBreadth() {
return b;
}
int getHeight() {
return h;
}
long long CalculateVolume() {
return (long long)l * b * h;
}
bool operator < (Box& B) {
if ((l < B.l) || ((b < B.b) && (l == B.l)) || ((h < B.h) && (l == B.l) && (b == B.b))) {
return true;
}
else return false;
};
};
std::ostream& operator<< (std::ostream& output, Box& B) {
output << B.getLenght() << " " << B.getBreadth() << " " << B.getHeight();
return output;
}
// =====================================================================================