Shape Class Reference

#include <shape.h>

Inheritance diagram for Shape:

Circle Rectangle Triangle List of all members.

Public Member Functions

 Shape (int x, int y)
 Shape (Point c)
Point getCenter () const
void setCenter (Point c)
virtual std::string getType () const=0
virtual double getArea () const=0

Protected Attributes

Point center

Detailed Description

An abstract base class that represents a shape on a 2D plane. Its only member is "center" which maintains the center point of the shape. It has pure virtual methods for identifying the type of shape and calculating the shape's area that must be implemented by subclasses.

Author:
Brent Nash


Constructor & Destructor Documentation

Shape::Shape ( int  x,
int  y 
)

Overloaded constructor that takes in an (x,y) coordinate.

Parameters:
x The X coordinate of the shape's center point in 2D space
y The Y coordinate of the shape's center point in 2D space

Shape::Shape ( Point  c  ) 

Overloaded constructor that takes in a center Point.

Parameters:
c The center point of the shape in 2D space


Member Function Documentation

Point Shape::getCenter (  )  const

Accessor for the shape's center point.

Precondition:
None
Postcondition:
Does not change the object
Returns:
The current center point of the shape as a Point object.

void Shape::setCenter ( Point  c  ) 

Mutator for the shape's center point.

Precondition:
None
Postcondition:
The "center" member variable of Shape will be changed to the input value.
Parameters:
c The new center point for the Shape.

virtual std::string Shape::getType (  )  const [pure virtual]

Pure virtual function for Shape subclasses. Returns a string indicating what type of shape this object is.

Precondition:
None
Postcondition:
Does not change the object
Returns:
A string name of the current shape

Implemented in Circle, Rectangle, and Triangle.

virtual double Shape::getArea (  )  const [pure virtual]

Pure virtual function for Shape subclasses. Subclasses overriding this method should use it to calculate the area of the shape and return the area as a floating point number.

Precondition:
Valid data must be set on the Shape object
Postcondition:
Does not change the object
Returns:
A floating point number representing the area of the Shape

Implemented in Circle, Rectangle, and Triangle.


Member Data Documentation

Point Shape::center [protected]

The center point of the shape as a 2D coordinate


The documentation for this class was generated from the following files:
Generated on Fri Dec 23 11:21:39 2011 by  doxygen 1.5.2