Forms with mutable Area
Polygon Class Reference

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

#include <polygon.h>

Inheritance diagram for Polygon:
Collaboration diagram for Polygon:

Public Member Functions

 Polygon (int n)
 Constructs a regular polygon with vertices on the unit circle. More...
 
 Polygon (Polygon const &)=default
 
std::string classname () const override
 
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...
 
float area () const override
 Computes the area of the closed polygon. More...
 
bool operator< (const Polygon &rhs) const
 Less operator regarding the perimeter. More...
 
- Public Member Functions inherited from Form
 Form (float x, float y)
 
 Form (Form const &)=default
 
float GetX () const
 
float GetY () const
 
virtual ~Form ()
 

Detailed Description

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

Definition at line 27 of file polygon.h.

Constructor & Destructor Documentation

◆ Polygon() [1/2]

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 33 of file polygon.cpp.

◆ Polygon() [2/2]

Polygon::Polygon ( Polygon const &  )
default

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 48 of file polygon.h.

◆ area()

float Polygon::area ( ) const
overridevirtual

Computes the area of the closed polygon.

Returns
Area of the closed polygon
Warning
Uses a mutable variable

Implements Form.

Definition at line 58 of file polygon.cpp.

Here is the call graph for this function:

◆ classname()

std::string Polygon::classname ( ) const
inlineoverridevirtual

Reimplemented from Form.

Definition at line 39 of file polygon.h.

Here is the call 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 54 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 76 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 44 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: