I modified my circleType class and added a few more functions which seems to have corrected the problem I just don't know if what I did is "correct." I will repost the circleType .h and .cpp for review by you all.
Feel free to hack away. I am just feeling myself through all this. My instructor is absent in all of this and when he does respond I wonder... This is his last:
"A large part of programming, as you are finding out, is “rolling up your shirt sleeve” and trying a solution or “if you don’t succeed…”. Also you will find that there is more than one way."
Well Duh!
NEW circleType.h
Code:
#ifndef H_CIRCLE
#define H_CIRCLE
#include <iostream>
#include <string>
#include <cmath>
#include "pointClass.h"
const double PI = 3.14159;
class circleType: public pointType
{
public:
circleType();
circleType(int xCoord, int yCoord, int radius);
void setRadius(int radius);
void setX(int xCoord);
void setY(int yCoord);
void setPoint(int xCoord, int yCoord);
void setPointRadius(int xCoord, int yCoord, int radius);
void getRadius(int & radius);
void getPointRadius(int & xCoord, int & yCoord, int & radius);
double calcArea();
double calcCircum();
void WhereAmI();
void printRadius() const;
void printPoint() const;
void printArea();
void printCircum();
void printPointRadius() const;
private:
pointType x, y, point;
int r;
};
#endif
NEW circleType.cpp
Code:
#include "pointClass.h"
#include "circleClass.h"
circleType::circleType()
:x(), y()
{
r = 0;
}
circleType::circleType(int xCoord, int yCoord, int radius)
: x(x), y(y)
{
r = radius;
}
void circleType::setPoint(int xCoord, int yCoord)
{
point.setPoint(xCoord, yCoord);
}
void circleType::setX(int xCoord)
{
point.setX(xCoord);
}
void circleType::setY(int yCoord)
{
point.setY(yCoord);
}
void circleType::setRadius(int radius)
{
r = radius;
}
void circleType::setPointRadius(int xCoord, int yCoord, int radius)
{
x.setX(xCoord);
y.setY(yCoord);
point.setPoint(xCoord, yCoord);
r = radius;
}
void circleType::getRadius(int & radius)
{
radius = r;
}
void circleType::getPointRadius(int & xCoord, int & yCoord, int & radius)
{
point.getX(xCoord);
point.getY(yCoord);
radius = r;
}
double circleType::calcArea()
{
return (PI * pow(r, 2));
}
double circleType::calcCircum()
{
return (2 * PI * r);
}
void circleType::printRadius() const
{
cout << "The current value of radius is: " << r << endl;
}
void circleType::printArea()
{
cout << "The area of a circle with a radius of "
<< r << " is " << calcArea() << endl;
}
void circleType::printCircum()
{
cout << "The circumference of a circle with a radius of "
<< r << " is " << calcCircum() << endl;
}
void circleType::printPoint() const
{
point.printPoint();
}
void circleType::printPointRadius() const
{
point.printPoint();
cout << " and the radius of the circle is " << r << "." << endl;
}
void circleType::WhereAmI()
{
int xCoord,
yCoord;
point.getPoint(xCoord, yCoord);
x.getX(xCoord);
y.getY(yCoord);
if (xCoord > 0 && yCoord > 0)
cout<< "My Center is in the first quadrant of the cartesian plane." << endl;
else if (xCoord > 0 && yCoord < 0)
cout << "My Center is in the second quadrant of the cartesian plane." << endl;
else if (xCoord < 0 && yCoord < 0)
cout << "My Center is in the third quadrant of the cartesian plane." << endl;
else
cout << "My Center is in the fourth quadrant of the cartesian plane." << endl;
}