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

Need help with this program i have the classs header file just need the cpp file

ID: 3841689 • Letter: N

Question

Need help with this program i have the classs header file just need the cpp file for circle and what goes in the main file. This program is in c++

// Cirlce header file

#ifndef CIRCLE_H
#define CIRLCE_H

class Circle
{
public:
Circle();
Circle(double);
double getArea() const;
double getRadius() const;
void setRadius(double);
static int getNumberOfObjects();

private:
double radius;
static int numberOfObjects;
};
#endif

14.3 (The Circle class) Implement the relational operators st) in the Circle class in Listing 10.9, CircleWithConstantMemberFunctions.h, to order the Circle objects according to their radii.

Explanation / Answer

Hi, Please find my implementation of all required function.

########### Circle.h #########

#ifndef CIRCLE_H
#define CIRCLE_H
class Circle
{
public:
Circle();
Circle(double);
double getArea() const;
double getRadius() const;
void setRadius(double);
static int getNumberOfObjects();

bool operator <(const Circle& other);
bool operator <=(const Circle& other);
bool operator ==(const Circle& other);
bool operator !=(const Circle& other);
bool operator >(const Circle& other);
bool operator >=(const Circle& other);
private:
double radius;
static int numberOfObjects;
};
#endif

########### Circle.cpp #########

#include "Circle.h"

Circle::Circle(){
    radius = 0;
    numberOfObjects++;
}

int Circle::numberOfObjects = 0;

Circle::Circle(double r){
   radius = r;
   numberOfObjects++;
}
double Circle::getArea() const{
   return 3.14*radius*radius;
}
double Circle::getRadius() const{
   return radius;
}
void Circle::setRadius(double r){
   radius = r;
}
int Circle::getNumberOfObjects(){
    return numberOfObjects;
}

// overloaded < operator
bool Circle::operator <(const Circle& other) {
if(radius < other.radius) {
return true;
}else
return false;
}

// overloaded <= operator
bool Circle::operator <=(const Circle& other) {
if(radius <= other.radius) {
return true;
}else
return false;
}

// overloaded == operator
bool Circle::operator ==(const Circle& other) {
if(radius == other.radius) {
return true;
}else
return false;
}

// overloaded != operator
bool Circle::operator !=(const Circle& other) {
if(radius != other.radius) {
return true;
}else
return false;
}

// overloaded > operator
bool Circle::operator >(const Circle& other) {
if(radius > other.radius) {
return true;
}else
return false;
}

// overloaded >= operator
bool Circle::operator >=(const Circle& other) {
if(radius >= other.radius) {
return true;
}else
return false;
}