Class to represent a box
| 3 | |
| 4 | // Class to represent a box |
| 5 | class Box |
| 6 | { |
| 7 | public: |
| 8 | Box() = default; |
| 9 | Box(double length, double width, double height) |
| 10 | : m_length{ length }, m_width{ width }, m_height{ height } |
| 11 | {} |
| 12 | |
| 13 | double getLength() const { return m_length; } |
| 14 | double getWidth() const { return m_width; } |
| 15 | double getHeight() const { return m_height; } |
| 16 | |
| 17 | void setLength(double length) { if (length > 0) m_length = length; } |
| 18 | void setWidth(double width) { if (width > 0) m_width = width; } |
| 19 | void setHeight(double height) { if (height > 0) m_height = height; } |
| 20 | |
| 21 | // Function to calculate the volume of a box |
| 22 | double volume() const { return m_length * m_width * m_height; } |
| 23 | |
| 24 | private: |
| 25 | double m_length{ 1.0 }; |
| 26 | double m_width{ 1.0 }; |
| 27 | double m_height{ 1.0 }; |
| 28 | }; |
| 29 | |
| 30 | #endif |
nothing calls this directly
no outgoing calls
no test coverage detected