#include <iostream.h>

long double pi = (long double) 3.1415926535897932384626433832795;

class Shape {
protected:
	int xPos;
	int yPos;
public:
	Shape(int x, int y);
	int getX();
	int getY();
	virtual double area();
};

class Circle : public Shape {
protected:
	double radius;
public:
	Circle(int x, int y, double r);
	virtual double area();
	friend ostream& operator<<(ostream& out, Circle& c);
};

class Rectangle : public Shape {
	double width;
	double height;
public:
	Rectangle(int x, int y, double w, double h);
	double area();
	friend ostream& operator<<(ostream& out, Rectangle& r);
};

class Cylinder : private Circle {
	int zPos;
	unsigned int height;
public:
	Cylinder(int x, int y, int z, double r, double h);
	double area();
	double volume();
	friend ostream& operator<<(ostream& out, Cylinder& c);
};

Shape::Shape(int x = 0, int y = 0) {
	xPos = x; yPos = y;
}

int Shape::getX() {
	return xPos;
}

int Shape::getY() {
	return yPos;
}

Circle::Circle(int x = 0, int y = 0, double r = 2) {
	radius = r;
	Shape(x, y);
}

double Circle::area() {
	return (pi*(radius*radius));
}

ostream& operator<<(ostream& out, Circle& c) {
	out << "Shape: Circle, Position: " << xPos << "," << yPos
		<< ", Radius: " << radius << ", Area: " << area();
}

Rectangle::Rectangle(int x = 0, int y = 0,
	double w = 2, double h = 2) {
	width = w;
	height = h;
	Shape(x, y);
}

double Rectangle::area() {
	return width * height;
}

ostream& operator<<(ostream& out, Rectangle& r) {
	out << "Shape: Rectangle, Position: " << xPos << "," << yPos
		<< ", Width: " << width << ", Height: " << height
		<< ", Area: " << area();
}

Cylinder::Cylinder(int x = 0, int y = 0, int z = 0,
	double r = 2, double h = 2) {
	zPos = z;
	height = h;
	Circle(x, y, r);
}

double Cylinder::area() {
	return 1;
}

double Cylinder::volume() {
	return height * Circle::area();
}

ostream& operator<<(ostream& out, Cylinder& c) {
	out << "Shape: Cylinder, Position: " << xPos << "," << yPos
		<< "," << zPos << ", Width: " << width
		<< ", Height: " << height << "Surface Area: " << area()
		<< ", Volume: " << volume();
}

int main() {
	Circle circle1(2, 3, 5.0);
	Circle circle2(10, 20, 12.0);
	Rectangle rectangle(23, 45, 10.0, 30);
	Cylinder cylinder1(1, 2, 3, 4.0, 10);
	Cylinder cylinder2(3, 7, 10, 5.0, 12);

	cout << circle1 << "\n" << circle2 << "\n" << rectangle << "\n"
		<< cylinder1 << "\n" << cylinder2;

	cout << "\nTotal Area: " << (circle1.area() + circle2.area()
		+ rectangle.area() + cylinder1.area() + cylinder2.area());

	cout << "\nTotal Volume: " <<
		(cylinder1.volume() + cylinder.volume());
}