Question: 1 8 . 1 Fall 2 0 2 4 Circle Class with Overloads Although this class has been done, it would be good practice to
Fall Circle Class with Overloads
Although this class has been done, it would be good practice to redo it
The overloaded operators are the only member functions being added
Circle color:String
radius:doubleCircle
CirclenewColor:String, newRadius:double
setColorcolor:String:void
setRadiusradius:double:void
getColor:String
getRadius:double
getArea:double
operator rhs: Circle:boolean
operator rhs: Circle:boolean
friend operator out: ostream& circle: const Circle&:ostream&
printCircleInfo:void
Create a class called Circle as describe below
Constructor with no arguments
Sets radius to and color to black
Constructor with arguments
Sets the color and radius to the values passed in
Get functions accessors return the field that the get refers to
getArea uses PI in the Math class to compute the area and return it
Set methods mutators set the field to the new values passed in to it
printCircleInfo
prints the color and area in the following format
The red circle has area
overloaded operators compare the areas of the circle
overloaded prints output
Circle Color: red Circle Radius:
Once you have tested the class, copy the main below. DO NOT CHANGE MAIN. If all of the methods in the class are correct, the main should give the correct answers. DO NOT CHANGE MAIN
Main
#include #include "Circle.h using namespace std; Circle createCircle; int main Circle circlepurple; Circle circle; circle createCircle; cout endl; circleprintCircleInfo; circleprintCircleInfo; Following statements use the operator overloads and that should be add to the Circle class cout endl; if circle circle cout "Circle has a smaller area than circle endl; if circle circle cout "Circle has the same area as circle endl; Following statements use the operator overloads that should be add to the Circle class cout "Circle Info" endl; cout circle; cout "Circle Info" endl; cout circle; cout Or you can print them both this way, too" endl; cout circle circle; return ; Function: createCircle Using the function call in main, write the function Check output for what it looks like Circle createCircle string color; double radius; cout "Enter the color: ; cin color; cout "Enter radius: ; cin radius; Circle circlecolor radius; return circle;
Sample Output
Enter the color: red Enter radius: The purple circle has an area of The red circle has an area of Circle has a smaller area than circle Circle Info Circle Color: purple Circle Radius: Circle Info Circle Color: red Circle Radius: Or you can print them both this way, too Circle Color: purple Circle Radius: Circle Color: red Circle Radius:
Sample Output
Enter the color: yellow Enter radius: The purple circle has an area of The yellow circle has an area of Circle has the same area as circle Circle Info Circle Color: purple Circle Radius: Circle Info Circle Color: yellow Circle Radius: Or you can print them both this way, too Circle Color: purple Circle Radius: Circle Color: yellow Circle Radius:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
