Mutable demo
Polygon Class Reference

Contains the description of a polygon, now with mutable. The traverse is stored. More...

#include <polygon.h>

Public Member Functions

 Polygon (int n)
 Constructs a regular polygon with vertices on the unit circle. More...
 
void append (const Point2D &a)
 Adds a vertex to the end of the polygon traverse. More...
 
int number () const
 Number of vertices in polygon. More...
 
float perimeter () const
 Computes the perimeter of the closed polygon. More...
 
bool operator< (const Polygon &rhs) const
 Less operator regarding the perimeter. More...
 

Detailed Description

Contains the description of a polygon, now with mutable. The traverse is stored.

Definition at line 76 of file polygon.h.

Constructor & Destructor Documentation

◆ Polygon()

Polygon::Polygon ( int  n)

Constructs a regular polygon with vertices on the unit circle.

Parameters
[in]nnumber of vertices in the polygon
Warning
We use a mutable member _peri which should be defined -1 whenever the class instance has been changed.

Definition at line 42 of file polygon.cpp.

Member Function Documentation

◆ append()

void Polygon::append ( const Point2D a)
inline

Adds a vertex to the end of the polygon traverse.

Parameters
[in]a2d point to add.

Definition at line 90 of file polygon.h.

Here is the caller graph for this function:

◆ number()

int Polygon::number ( ) const
inline

Number of vertices in polygon.

Returns
Number of vertices of the open polygon

Definition at line 96 of file polygon.h.

Here is the caller graph for this function:

◆ operator<()

bool Polygon::operator< ( const Polygon rhs) const
inline

Less operator regarding the perimeter.

Parameters
[in]rhssecond polygon.
Returns
True iff perimeter of recent instance is less than the perimeter of the second instance.

Definition at line 110 of file polygon.h.

Here is the call graph for this function:

◆ perimeter()

float Polygon::perimeter ( ) const

Computes the perimeter of the closed polygon.

Returns
Perimeter of the closed polygon
Warning
Uses a mutable variable

Definition at line 53 of file polygon.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following files: