I need help with this C++ code and would like to impliment the bonus as well. Th
ID: 3729738 • Letter: I
Question
I need help with this C++ code and would like to impliment the bonus as well. Thank you!
Mandatory Instructions Declare a Circie class that descibes the size and position of a Circle object on anx, y axis and create a demonstration program to test it 1. First, create a file called labó.h to hold your Circle class definition. Your class should include the private data members and setter and getter function prototypes described below. Don't forget to add the include guard preprocessor statements (#0hdof #dome and endi) to the file. a. Private data membe radius, xPos, yPos b. Public member functions (arrange accessor and mutator functions into two clearly documented groups) - setRadius, serxPos, sety Pos to set the private data members individually - getRadius, getxPos, gety Pos to get the private data members 2. Create a file called laboclient.cpp to test your class. It should include a main function to Define (instantiate) a Circie object called ring a. b. Prompt the user to enter a radius and x, y coordinates for the ring object and store these values in the ring's private data members. c. Display the ring object's radnus, xPos andyPos values, using the getter fumctions to get the values to display Don't forget to include labó.h in this file. Conapile your program (g+labóclient.cpp) and test it to make sure it works correctly. each one with your ring object before going on to the next one a. displayCircle displays the radius, xPos and yPos values of a Circle object. Notice this will replace the need for the main 3. Create a file called lab6.cpp to hold the function implementations for the two additional member functions described below. Test function to call the three getter functions to display the objects data. Call this function after you enter values for the radius, and yPos. For example, if you enter 6, 12 and 7 your output should look like this: The Circle object with radius 6 has coordinares (12, 7). b. moveCircle has two parameters used to move the Circle object horizontally and vertically on the x, y axis - The first parameter indicates how much to move the circle to the right (if the value is positive) or left (if the value is negative) Do not use any if statements here! - Th econd parameter indicates how nuch to move the circle up (if the value is positive) or down (if the value is negative). Do not use any if statements here! Tip 1: Don't forget to add a prototype for each function to the Circle class declaration in the lab6.h file. Tip 2: Include lab6h in the file lab6.cpp Tip 3: Use the compile statement. g--lab6.cpp laboclientgp 4. Prompt the user to enter anx move and y move value. Use these values to move the ring object on the , y axis.Explanation / Answer
Please find below code for the program:
lab6.h
#ifndef __LAB6_H__
#define __LAB6_H__
#include <iostream>
class Circle {
double radius;
double xPos;
double yPos;
public:
void setRadius(double r) {
radius = r;
}
void setxPos(double x){
xPos = x;
}
void setyPos(double y){
yPos = y;
}
double getRadius(){
return radius;
}
double getxPos(){
return xPos;
}
double getyPos(){
return yPos;
}
void displayCircle();
void moveCircle(double, double);
void displayQuad();
};
#endif
lab6.cpp
#include "lab6.h"
using namespace std;
void Circle::displayCircle() {
cout<<"The Circle object with radius "<<radius<<" has coordinate ("<<xPos<<","<<yPos<<"). ";
}
void Circle::moveCircle(double horizontal, double vertical) {
xPos = xPos + horizontal;
yPos = yPos + vertical;
}
void Circle::displayQuad() {
int quad;
if(xPos > 0 && yPos > 0) {
quad = 1;
}
else if(xPos < 0 && yPos > 0) {
quad = 2;
}
else if(xPos > 0 && yPos < 0) {
quad = 4;
}
else if(xPos < 0 && yPos < 0) {
quad = 3;
}
cout<<"The Circle object is in Quadrant "<<quad<<endl;
}
lab6client.cpp
#include <iostream>
#include "lab6.h"
using namespace std;
int main() {
Circle ring;
double r, x, y;
// cout<<"Enter radius: ";
// cin>>r;
// cout<<"Enter xPos: ";
// cin>>x;
// cout<<"Enter yPos: ";
// cin>>y;
cout<<"Please enter r,x,y ";
cin>>r>>x>>y;
ring.setRadius(r);
ring.setxPos(x);
ring.setyPos(y);
// cout<<"Ring radius: "<<ring.getRadius()<<endl;
// cout<<"Ring xPos: "<<ring.getxPos()<<endl;
// cout<<"Ring yPos: "<<ring.getyPos()<<endl;
cout<<"Q1 ";
ring.displayCircle();
ring.displayQuad();
double xMov, yMov;
// cout<<"Enter X move value: ";
// cin>>xMov;
// cout<<"Enter Y move value: ";
// cin>>yMov;
cout<<"Please enter delta x, delta y ";
cin>>xMov>>yMov;
ring.moveCircle(xMov,yMov);
ring.displayCircle();
ring.displayQuad();
cout<<"Q4 ";
return 0;
}