Box It!

  • + 0 comments

    Python main learning C++ 🤪

    class Box{
        private:
            int l;
            int b;
            int h;
        public:
            Box(){
                l = 0;
                b = 0;
                h = 0;
            }
            
            Box(int length, int breadth, int height){
                l = length;
                b = breadth;
                h = height;
            }
            int getLength(){
                return l;
            } 
            int getBreadth(){
                return b;
            }
            int getHeight(){
                return h;
            }
            long long CalculateVolume(){
                return static_cast<long long>(l)*b*h;
            }
            
            bool operator<(Box& other) const{
                if(l < other.l){
                    return true;
                }
                else if(b < other.b && l == other.l){
                    return true;
                }
                else if(h < other.h && b == other.b && l == other.l){
                    return true;
                }
                
                return false;
            }
            
            friend ostream& operator<<(ostream& os, const Box& other) {
                os << other.l << " " << other.b << " " << other.h;
                return os;
            }
            
    };