Write a brand new driver program that does the following: Creates a circle object circleOne at (0,0):5. Creates a pointer c1Ptr to circleOne Creates a circle object circleTwo at (-2,-2): 10 Creates a pointer c2Ptr to circleTwo Use greaterThan to check if circleTwo is bigger than circleOne and display results Declare an array of pointers to circles- circlePointerArray Call a function with signature inputData(circlePointerArray, string filename) that reads data from a file called dataLab4.txt into the array The following h-k are done in this function Use istringstream to create an input string stream called instream. Initialize it with each string that is read from the data file using the getline method. Read the coordinates for the center and the radius from instream to create the circles Include a try catch statement to take care of the exception that would occur if there was a file open error. Display the message “File Open Error” and exit if the exception occurs Display all the circles in this array of pointers using the toString method Display the sum of the areas of all the circles in the array Switch the position of the second and fourth circles by swapping pointers to the circles Display this changed sequence of circles using toString method
Write a brand new driver program that does the following: Creates a circle object circleOne at (0,0):5. Creates a pointer c1Ptr to circleOne Creates a circle object circleTwo at (-2,-2): 10 Creates a pointer c2Ptr to circleTwo Use greaterThan to check if circleTwo is bigger than circleOne and display results Declare an array of pointers to circles- circlePointerArray Call a function with signature inputData(circlePointerArray, string filename) that reads data from a file called dataLab4.txt into the array The following h-k are done in this function Use istringstream to create an input string stream called instream. Initialize it with each string that is read from the data file using the getline method. Read the coordinates for the center and the radius from instream to create the circles Include a try catch statement to take care of the exception that would occur if there was a file open error. Display the message “File Open Error” and exit if the exception occurs Display all the circles in this array of pointers using the toString method Display the sum of the areas of all the circles in the array Switch the position of the second and fourth circles by swapping pointers to the circles Display this changed sequence of circles using toString method
Write a brand new driver program that does the following: Creates a circle object circleOne at (0,0):5. Creates a pointer c1Ptr to circleOne Creates a circle object circleTwo at (-2,-2): 10 Creates a pointer c2Ptr to circleTwo Use greaterThan to check if circleTwo is bigger than circleOne and display results Declare an array of pointers to circles- circlePointerArray Call a function with signature inputData(circlePointerArray, string filename) that reads data from a file called dataLab4.txt into the array The following h-k are done in this function Use istringstream to create an input string stream called instream. Initialize it with each string that is read from the data file using the getline method. Read the coordinates for the center and the radius from instream to create the circles Include a try catch statement to take care of the exception that would occur if there was a file open error. Display the message “File Open Error” and exit if the exception occurs Display all the circles in this array of pointers using the toString method Display the sum of the areas of all the circles in the array Switch the position of the second and fourth circles by swapping pointers to the circles Display this changed sequence of circles using toString method
Write a brand new driver program that does the following:
Creates a circle object circleOne at (0,0):5.
Creates a pointer c1Ptr to circleOne
Creates a circle object circleTwo at (-2,-2): 10
Creates a pointer c2Ptr to circleTwo
Use greaterThan to check if circleTwo is bigger than circleOne and display results
Declare an array of pointers to circles- circlePointerArray
Call a function with signature inputData(circlePointerArray, string filename) that reads data from a file called dataLab4.txt into the array The following h-k are done in this function
Use istringstream to create an input string stream called instream. Initialize it with each string that is read from the data file using the getline method.
Read the coordinates for the center and the radius from instream to create the circles
Include a try catch statement to take care of the exception that would occur if there was a file open error. Display the message “File Open Error” and exit if the exception occurs
Display all the circles in this array of pointers using the toString method
Display the sum of the areas of all the circles in the array
Switch the position of the second and fourth circles by swapping pointers to the circles
Display this changed sequence of circles using toString method
Here is a starter code:
int main(){ // declare two pointers to circles and create them using "new " memory from the heap Circle *One = new Circle(0,0,0); Circle *Two = new Circle(1,1,1); if (One->greaterThan(Two)) cout<<" Circle One is bigger "<<endl; else cout<<" Circle Two is bigger "<<endl; // create an array of pointers to circles Circle *circlePointerArray[SIZE]; //populate the pointer array with circles from the data file and return the number of circles created int count = inputData(circlePointerArray, "dataLab4.txt"); //rest of the code } **************** Static Function in Driver ************************ //pointer to pointer works //Circle * circlePointer[] of course works int inputData(Circle **circlePointerArray, string filename) // function header for inputting data from data file into Circle array *****************Instance Method in Circle Class********************* bool Circle::greaterThan(Circle * other){ // method that compares two circles using radius as key and returns true if return this->radius > other->getRadius(); // "this circle" is greater than the "other circle". Note the use of -> }
My code:
Main.cpp:
in attachment
Circle.cpp:
in attachment
Circle.h:
in attachment
dataLab4.txt:
0 0 4 0 0 12 -2 -9 11 4 5 7 7 8 9 2 -5 11
Here is the required output:
Expert Solution
Step 1
This is a C++ program.
Driver program means main() that we write to execute the class or function we have defined already.
Concept of constructor, vectors, pointers, double pointers i.e pointers to pointers is used to write the main( ).
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.