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

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.

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.
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.

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.

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:
 All Classes Functions Variables Friends

Generated by  doxygen 1.6.2
The University of Southern California does not screen or control the content on this website and thus does not guarantee the accuracy, integrity, or quality of such content. All content on this website is provided by and is the sole responsibility of the person from which such content originated, and such content does not necessarily reflect the opinions of the University administration or the Board of Trustees