//
//   A class hierarchy of different types of figures.  It will be used
//   to demonstrate virtual functions and polymorphism.
//
 
#ifndef Figure_h_
#define Figure_h_

//  "Figure" is now an abstract base class. 

class Figure {
public:
	Figure() {}
	virtual void Output_Info( ) = 0;
	virtual float Area( ) { return 0.0; }   // defaults to 0.0 if not redefined
	virtual float Volume( ) { return 0.0; } // defaults to 0.0 if not redefined
};


//
//  "Rectangle" is  derived class of "Figure".  Note that it does not
//  redefine the "Volume" member function because rectangles have 0
//  volume.
//
class Rectangle : public Figure {
public:
	Rectangle( float height_in, float width_in );
	virtual void Output_Info( );
	virtual float Area( );
protected:
	float height, width;
};


//
//  "Square" is derived class of "Rectangle".  It has neither its own
//  variables nor its own Area function.  These are inherited from
//  Rectangle.  The constructor ensures that the height and width are
//  the same.
//
class Square : public Rectangle {
public:
	 Square( float side );
	 virtual void Output_Info( );
};


//
//  "Circle" is  derived class of "Figure".  Note that it does not
//  redefine the "Volume" member function because circles have 0
//  volume.
//
class Circle : public Figure {
public:
	 Circle( float radius_in );
	 virtual void Output_Info( );
	 virtual float Area( );
	 float GetRadius() { return radius; }

protected:
	 float radius;
};
  

//
//  "Cylinder" is derived from "Figure".  It includes a circle as a 
//  member variable and uses the circle area function in computing
//  area and volume. 
//
class Cylinder : public Circle {
public:
	 Cylinder( float radius_in, float height_in );
	 virtual void Output_Info( );
	 virtual float Area( );
	 virtual float Volume( );

protected:
	 float height;
	 Circle base;
};
  
//
//  "Sphere" is  derived class of "Figure".  It redefines both the
//  "Area" (surface area) and "Volume" member functions.
//
class Sphere : public Figure {
public:
	Sphere( float radius_in );
	virtual void Output_Info( );
	virtual float Area( );
	virtual float Volume( );
private:
	float radius;
};

#endif
  
