text cover

Data Abstraction and Problem Solving with C++

Walls and Mirrors

by Frank M. Carrano

Addison Wesley Logo

Sphere Class Reference

#include <Sphere.h>

List of all members.


Detailed Description

Definition of a class of Spheres.

Definition at line 22 of file Sphere.h.

Public Member Functions

 Sphere ()
 Sphere (double initialRadius)
void setRadius (double newRadius)
double getRadius () const
double getDiameter () const
double getCircumference () const
double getArea () const
double getVolume () const
void displayStatistics () const

Private Attributes

double theRadius


Constructor & Destructor Documentation

Sphere::Sphere  ) 
 

Default constructor: Creates a Sphere and initializes its radius to a default value.

Precondition:
None.
Postcondition:
A Sphere of radius 1 exists.

Definition at line 23 of file Sphere.cpp.

Sphere::Sphere double  initialRadius  ) 
 

Constructor: Creates a Sphere and initializes its radius.

Precondition:
initialRadius is the desired radius.
Postcondition:
A Sphere of radius initialRadius exists.
Parameters:
initialRadius The given radius.

Definition at line 27 of file Sphere.cpp.

References theRadius.


Member Function Documentation

void Sphere::setRadius double  newRadius  ) 
 

Sets (alters) the radius of an existing Sphere.

Precondition:
newRadius is the desired radius.
Postcondition:
The Sphere's radius is newRadius.
Parameters:
newRadius The new radius.

Definition at line 35 of file Sphere.cpp.

References theRadius.

Referenced by main().

double Sphere::getRadius  )  const
 

Determines a Sphere's radius.

Precondition:
None.
Postcondition:
None.
Returns:
The radius.

Definition at line 43 of file Sphere.cpp.

References theRadius.

Referenced by displayStatistics().

double Sphere::getDiameter  )  const
 

Determines a Sphere's diameter.

Precondition:
None.
Postcondition:
None.
Returns:
The diameter.

Definition at line 48 of file Sphere.cpp.

References theRadius.

Referenced by displayStatistics(), getCircumference(), and main().

double Sphere::getCircumference  )  const
 

Determines a Sphere's circumference.

Precondition:
PI is a named constant.
Postcondition:
None.
Returns:
The circumference.

Definition at line 53 of file Sphere.cpp.

References getDiameter(), and PI.

Referenced by displayStatistics().

double Sphere::getArea  )  const
 

Determines a Sphere's surface area.

Precondition:
PI is a named constant.
Postcondition:
None.
Returns:
The surface area.

Definition at line 58 of file Sphere.cpp.

References PI, and theRadius.

Referenced by displayStatistics().

double Sphere::getVolume  )  const
 

Determines a Sphere's volume.

Precondition:
PI is a named constant.
Postcondition:
None.
Returns:
The volume.

Definition at line 63 of file Sphere.cpp.

References PI, and theRadius.

Referenced by displayStatistics().

void Sphere::displayStatistics  )  const
 

Displays statistics of a Sphere.

Precondition:
None.
Postcondition:
Displays the radius, diameter, circumference, area, and volume.

Definition at line 69 of file Sphere.cpp.

References getArea(), getCircumference(), getDiameter(), getRadius(), and getVolume().

Referenced by main().


Member Data Documentation

double Sphere::theRadius [private]
 

The Sphere's radius

Definition at line 81 of file Sphere.h.

Referenced by getArea(), getDiameter(), getRadius(), getVolume(), setRadius(), and Sphere().


The documentation for this class was generated from the following files:

Generated on Sun Aug 27 11:56:47 2006 for AWLogo by  doxygen 1.4.6