#include <iostream>
#include <cmath>
using namespace std;


// Triangle Class
class Triangle{
private:
	unsigned numSides;
	double width;
	double height;

public:
	// Constructor for Triangle
	Triangle(double w, double h){
		this->width = w;
		this->height = h;
		this->numSides = 3;
	}

	void setDimensions(double w, double h){
		this->width = w;
		this->height = h;

	}

	double getArea() {
		// Area of a triangle is (width * height) / 2
		return (this->width * this->height) / 2.0;
	}
};


// Square Class
class Square{
private:
	unsigned numSides;
	double width;
	double height;

public:
	// Constructor for Square
	Square(double w){
		this->width = w;
		this->height = w;
		this->numSides = 4;
	}

	double getArea(){
		// Area of a square is the square of a side
		return (pow(this->width,2));
	}

	void printnumSides(){
		for(int i=0; i<this->numSides; i++){
			cout << "side " << i+1 << ": " << this->width << endl;
		}
		return;
	}
};


// Circle Class
class Circle{
private:
	unsigned numSides;
	double width;
	double height;
	double diameter;
	double radius;

public:
	// Constructor for Circle
	Circle(double d){
		this->width = this->height = this->diameter = d;
		this->radius = this->diameter/2;
		this->numSides = 1;
	}

	double getArea() {
		// Area of a circle is pi * r^2
		return (M_PI * pow(this->radius,2));
	}
};


int main() {
	Circle myCircle(5.0);
	Triangle myTriangle(5.0, 4.0);
	Square mySquare(5.0);

	// Access base class method via derived class object
	myTriangle.setDimensions(6.0, 5.0);

	cout << "Sides of the square:\n";
	mySquare.printnumSides();

	// Call derived class's overridden method
	cout << "Area of the triangle: " << myTriangle.getArea() << endl;
	cout << "Area of the square: " << mySquare.getArea() << endl;
	cout << "Area of the circle: " << myCircle.getArea() << endl;	

	return 0;
}
