Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

class Circle { private: //The radius of the circle double radius; //Color of the

ID: 3848746 • Letter: C

Question

class Circle { private: //The radius of the circle double radius; //Color of the circle string color; public: //Construct a default circle object Circle(); //Construct a circle object with given radius Circle(double newRadius); / //Accessor (get- ) functions double getRadius(); string getColor(); //Mutator (set - ) functions void setRadius(double R); void setColor(string C); //Return the area of this circle double getArea(); //compare this circle with another one //returns "true" if this circle is larger //false - otherwise bool compareCircles(Circle anotherCircle); }; //class methods (functions) definition //creates a circle with radius=1, no color specified Circle::Circle() { radius = 1; } //creates a "white" circle with radius passed as parameter Circle::Circle(double newRadius) { //place your code here } //Accessor functions double Circle::getRadius() { return radius; } string Circle::getColor() { return color; } //Mutator functions void Circle::setRadius(double R) { radius = R; } void Circle::setColor(string C) { color = C; } double Circle::getArea() { //p[lace your code here } bool Circle::compareCircles(Circle anotherCircle) { //place your code here }

Hello I need the codes for the bolt place and the header file and program file seprately. thanks

Explanation / Answer

1. circle.h

#include<iostream>
#include<string>

using namespace std;

class Circle {
     private:
          double radius;//The radius of the circle double radius;
          string color;//Color of the circle string color;
    public:

        //Construct a default circle object Circle();
        Circle();
          
        //Construct a circle object with given radius
        Circle(double newRadius);
         //Accessor (get- ) functions
          double getRadius();

        string getColor();
        //Mutator (set - ) functions
        void setRadius(double R);

         void setColor(string C);

        //Return the area of this circle
         double getArea();

           //compare this circle with another one
           //returns "true" if this circle is larger
           //false - otherwise
         bool compareCircles(Circle anotherCircle);


         };

2. below is the code required

#include "circle.h"

   Circle::Circle(double newRadius)
             {
                 radius=newRadius;
                 color="white";
             }

   double Circle::getArea()
   {
    return 3.14*radius*radius;

    }

    bool Circle::compareCircles(Circle anotherCircle) {

            if(radius>anotherCircle.radius)
                return true;
             else
                return false;
         }

3. circle.cpp

#include "circle.h"
            //class methods (functions) definition
            //creates a circle with radius=1, no color specified
            Circle::Circle()
             {
                 radius = 1;
                 }

            //creates a "white" circle with radius passed as parameter

                 Circle::Circle(double newRadius)
             {
                 radius=newRadius;
                 color="white";
             }
                 //Accessor functions
                 double Circle::getRadius()
                  {
                      return radius;
                       }
                  string Circle::getColor()
                   {
                       return color;
                        }
                  //Mutator functions
                  void Circle::setRadius(double R)
                   {
                      radius = R;
                       }
                  void Circle::setColor(string C)
                  {
                      color = C;
                   }

   double Circle::getArea()
   {
    return 3.14*radius*radius;

    }

    bool Circle::compareCircles(Circle anotherCircle) {

            if(radius>anotherCircle.radius)
                return true;
             else
                return false;
         }