A rectangle defined by width and height. More...
#include <shapes.hpp>
Public Member Functions | |
| Rectangle (double width, double height) | |
| Construct a rectangle. | |
| double | area () const override |
| Compute the area of the shape. | |
| double | height () const |
| Get the height. | |
| std::string | name () const override |
| Return the human-readable name of the shape. | |
| double | perimeter () const override |
| Compute the perimeter of the shape. | |
| double | width () const |
| Get the width. | |
Public Member Functions inherited from geometry::Shape | |
| virtual | ~Shape ()=default |
| Virtual destructor for safe polymorphic deletion. | |
| std::string | describe () const |
| Pretty-print shape information. | |
Protected Attributes | |
| double | height_ |
| The rectangle's height. | |
| double | width_ |
| The rectangle's width. | |
Additional Inherited Members | |
Static Public Member Functions inherited from geometry::Shape | |
| static int | instance_count () |
| Get the total count of Shape instances created. | |
Protected Member Functions inherited from geometry::Shape | |
| Shape () | |
| Increment the instance counter. | |
A rectangle defined by width and height.
\[ A = w \times h, \qquad P = 2(w + h) \]
Definition at line 138 of file shapes.hpp.
|
inline |
Construct a rectangle.
| width | The width (must be positive). |
| height | The height (must be positive). |
Definition at line 145 of file shapes.hpp.
References height(), height_, width(), and width_.
Referenced by geometry::Square::Square().
|
inlinenodiscardoverridevirtual |
Compute the area of the shape.
Implements geometry::Shape.
Definition at line 147 of file shapes.hpp.
|
inlinenodiscard |
Get the height.
Definition at line 160 of file shapes.hpp.
References height_.
Referenced by Rectangle().
|
inlinenodiscardoverridevirtual |
Return the human-readable name of the shape.
"Circle", "Rectangle", etc. Implements geometry::Shape.
Reimplemented in geometry::Square.
Definition at line 155 of file shapes.hpp.
|
inlinenodiscardoverridevirtual |
Compute the perimeter of the shape.
Implements geometry::Shape.
Definition at line 151 of file shapes.hpp.
|
inlinenodiscard |
Get the width.
Definition at line 158 of file shapes.hpp.
References width_.
Referenced by Rectangle().
|
protected |
The rectangle's height.
Definition at line 164 of file shapes.hpp.
Referenced by Rectangle(), area(), height(), and perimeter().
|
protected |
The rectangle's width.
Definition at line 163 of file shapes.hpp.
Referenced by Rectangle(), area(), perimeter(), geometry::Square::side(), and width().