// @topic W15-1-020 class inheritance and pure interface
// @brief implementation of classes Circle, Rectangle and Square
#include "shapes.h"
//-------------------------------------
// implementation for the Circle class
//-------------------------------------
Circle::Circle( double radius_ )
: radius( radius_ )
{
}//Circle::Circle
double Circle::get_area() const
{
return PI * radius * radius;
}//Circle::get_area
double Circle::get_perimeter() const
{
return circumference();
}
double Circle::circumference() const
{
return 2 * PI * radius;
}//Circle::circumference
//-------------------------------------
// implementation for the Rectangle class
//-------------------------------------
Rectangle::Rectangle( double width_, double height_ )
: width( width_ ), height( height_ )
{
}//Rectangle::Rectangle
double Rectangle::get_area() const
{
return width * height;
}//Rectangle::get_area
double Rectangle::get_perimeter() const
{
return 2 * ( width + height );
}//Rectangle::get_perimeter
//-------------------------------------
// implementation for the Square class
//-------------------------------------
Square::Square( double side )
:
Rectangle( side, side )
{
}//Square::Square