Question: C++ GeometricObject Class A Fields color PI valid Colors Methods calculate Area calculatePerimeter GeometricObject getColor e proper Cap setColor toString Circle Class GeometricObject public A

C++

C++ GeometricObject Class A Fields color PI valid Colors Methods calculate Area

calculatePerimeter GeometricObject getColor e proper Cap setColor toString Circle Class GeometricObject public

A Ring Class + Circle Fields radius Methods calculate Area calculate Perimeter

Circle getRadius setRadius toString public Fields Inner Radius Methods @calculate Area calculatePerimeter

egetInner Radius Ring setinnerRadius toString The diagram illustrates the Hierarchy-GeometricObject-Circle-Ring. The implementation

GeometricObject Class A Fields color PI valid Colors Methods calculate Area calculatePerimeter GeometricObject getColor e proper Cap setColor toString Circle Class GeometricObject public A Ring Class + Circle Fields radius Methods calculate Area calculate Perimeter Circle getRadius setRadius toString public Fields Inner Radius Methods @calculate Area calculatePerimeter egetInner Radius Ring setinnerRadius toString The diagram illustrates the Hierarchy-GeometricObject-Circle-Ring. The implementation of GeometricObject and Circle is provided below. You are asked to supply the Ring class by reverse-engineering the hierarchy shown above. r1 The Ring class represents a solid circular band with an outer and inner radius (say rl and r2 respectively). See figure on the right. Only the segment enclosed between rl and r2 is considered part of the ring. r2 Design Specifications 1. The Ring class is a public descendant of the Circle class. 2. It enhances the Circle definition by including a second radius used to set the inner face of the circular figure Main #include "Geometricobject.h" #include "Circle.h" #include "Ring.h" int main() { cout #include #include #include #include using namespace std; //Declaration section class Geometricobject { private: string color; //utility routine to force text to proper cap format string properCap(string original); //list of valid colors - children may reduce it but not enlarge it vector validColors{ "White", "Red", "Blue" }; public: const double PI = 3.1415; //Accessors -Mutators void setColor(string c); string getColor() { return color; } //Constructor Geometricobject(string c = "Blue") { setColor(); } //User-defined functions virtual string toString(); //Descendants MUST implement it virtual double calculateArea() = 0; //PURE VIRTUAL virtual double calculatePerimeter() = 0; //PURE VIRTUAL }; // IMPLEMENTATION SECTION string Geometricobject::toString() { stringstream sout; sout radius = abs(radius); } // constructors Circle(double radiusValue = 0, string colorValue = "Red") : Geometricobject(colorValue) { setRadius (radiusValue); } //programmer-defined methods string toString() override; double calculateArea() override { return PI * radius * radius; } double calculatePerimeter() override { return 2 * PI * radius; } }; // IMPLEMENTATION string Circle::toString() { stringstream sout; sout #include #include #include #include using namespace std; //Declaration section class Geometricobject { private: string color; //utility routine to force text to proper cap format string properCap(string original); //list of valid colors - children may reduce it but not enlarge it vector validColors{ "White", "Red", "Blue" }; public: const double PI = 3.1415; //Accessors -Mutators void setColor(string c); string getColor() { return color; } //Constructor Geometricobject(string c = "Blue") { setColor(); } //User-defined functions virtual string toString(); //Descendants MUST implement it virtual double calculateArea() = 0; //PURE VIRTUAL virtual double calculatePerimeter() = 0; //PURE VIRTUAL }; // IMPLEMENTATION SECTION string Geometricobject::toString() { stringstream sout; sout radius = abs(radius); } // constructors Circle(double radiusValue = 0, string colorValue = "Red") : Geometricobject(colorValue) { setRadius (radiusValue); } //programmer-defined methods string toString() override; double calculateArea() override { return PI * radius * radius; } double calculatePerimeter() override { return 2 * PI * radius; } }; // IMPLEMENTATION string Circle::toString() { stringstream sout; sout

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!