Design a derived class circleType. Every circle has a center and a radius. Given
ID: 3628230 • Letter: D
Question
Design a derived class circleType.Every circle has a center and a radius. Given the radius, we can determine the circle’s area and circumference. Given the center, we can determine the position in the x-y plane. The center of a circle is a point in the x-y plane. Design a class, circleType, that can store the radius and center of the circle. Because the center is a point in the x-y plane and you designed the class to capture the properties of a point in the pointType class., you must derive the class circleType from the class pointType. You should be able to perform the usual operations on a circle, such as setting the radius, printing the radius, calculating and printing the area and circumference, and carrying out the usual operations on the center.
Write a test program to test the various operations.
// Specification of circleType
class circleType: public pointType
{
public:
void print() const;
void setRadius(double r);
double getRadius() const;
double getCircumference() const;
double getArea() const;
circleType(double x = 0.0, double y = 0.0, double r = 0.0);
protected:
double radius;
};
Explanation / Answer
#include using namespace std; // Specification of circleType class circleType: public pointType { public: void print() const; void setRadius(double r); double getRadius() const; double getCircumference() const; double getArea() const; circleType(double x = 0.0, double y = 0.0, double r = 0.0); protected: double radius; }; void circletype::print() const { coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.