Function to calculate the volume of a Carton object
| 15 | |
| 16 | // Function to calculate the volume of a Carton object |
| 17 | double volume() const override |
| 18 | { |
| 19 | const double volume {(m_length - 0.5) * (m_width - 0.5) * (m_height - 0.5)}; |
| 20 | return std::max(volume, 0.0); // Or: return volume > 0.0 ? volume : 0.0; |
| 21 | } |
| 22 | private: |
| 23 | std::string m_material; |
| 24 | }; |