This is data structure class. instructions below, read carefully. after completi
ID: 3884350 • Letter: T
Question
This is data structure class.
instructions below, read carefully.
after completing the steps in the aforementioned “Getting started” section, you are tasked with the following changes to project:
Run Main.cpp and note the blocks of code hidden by the #if macros. These blocks are blocked out because this file (Main.cpp) would not compile if they weren’t blocked out because the Circle class does not exist yet. Below is the Circle you are to implement in a manner similar to the Rectangleclass.
In addition to implementing this class, you are to create a CircleUnitTest class in the src/test/cppfolder in a manner similar to what you see in the RectangleUnitTest class.
NOTE: It is suggested that you carefully study the RectangleUnitTest class carefully and observe that you are also to add at least two more tests to that test suite. In fact, it is recommended that you start with that task before you write your own test suite from scratch. Your instructor will walk you through this effort, so pay attention!
clion codes below with todo list:
thing» Circle (radius > } -radius: length unit t +Circle(theRadius: length_unit t-1) +getRadius ) const lengthunitt +getCircumference() const: lengthunit t +getArea) const: length_unit_ftExplanation / Answer
Ans:
Circle class:
#include<iostream>
#define PI 3.14159
using namespace std;
class Circle
{
private:
double radius;
public:
Circle(double theRadius);
double getRadius(void);
double getCircumference();
double getArea();
void unitCircle(void);
};
Circle::Circle(double theRadius)
{
if(theRadius>0)
radius = theRadius;
else
{
cout<<"Invalid Radius"<<endl;
}
}
double Circle::getRadius(void)
{
return radius;
}
double Circle::getCircumference(void)
{
return 2*PI*radius;
}
double Circle::getArea(void)
{
return PI*radius*radius;
}
void Circle::unitCircle(void)
{
radius = 1;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.