int x //x coord of the center -int y // y coord of the center -int radius -static int count // static variable to keep count of number of circles created + Circle() //default constructor that sets origin to (0,0) and radius to 1 +Circle(int x, int y, int radius) // regular constructor +getX(): int +getY(): int +getRadius(): int +setX(int newX: void +setY(int newY): void +setRadius(int newRadius):void +getArea(): double // returns the area using formula pi*r^2 +getCircumference // returns the circumference using the formula 2*pi*r +toString(): String // return the circle as a string in the form (x,y) : radius +getDistance(Circle other): double // * returns the distance between the center of this circle and the other circle +moveTo(int newX,int newY):void // * move the center of the circle to the new coordinates +intersects(Circle other): bool //* returns true if the center of the other circle lies inside this circle else returns false +resize(double scale):void// * multiply the radius by the scale +resize(int scale):Circle // * returns a new Circle with the same center as this circle but radius multiplied by scale +getCount():int //returns the number of circles created //note that the resize function is an overloaded function. The definitions have different signatures   Data file: 0 0 4 0 0 6 - 2 -9 6 4 5 7 7 8 9   Extend the driver class to do the following: Declare a vector of circles Call a function with signature inputData(vector &, string filename) that reads data from a file called dataLab4.txt into the vector. The following c-e 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 vector using the toString method Use an iterator to iterate through the vector to display these circles Display the count of all the circles in the vector using the getCount method Display the count of all the circles in the vector using the vector size method Clear the vector Create a circle called c using the default constructor Display the current count of all the circles using the getCount method on c Display the current count of all the circles using the vector size method   Write functions in your main driver cpp file that perform the actions b-l. Your code should be modular and your main program should consist primarily of function calls

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

-int x //x coord of the center

-int y // y coord of the center

-int radius

-static int count // static variable to keep count of number of circles created

+ Circle() //default constructor that sets origin to (0,0) and radius to 1

+Circle(int x, int y, int radius) // regular constructor

+getX(): int

+getY(): int

+getRadius(): int

+setX(int newX: void

+setY(int newY): void

+setRadius(int newRadius):void

+getArea(): double // returns the area using formula pi*r^2

+getCircumference // returns the circumference using the formula 2*pi*r

+toString(): String // return the circle as a string in the form (x,y) : radius

+getDistance(Circle other): double // * returns the distance between the center of this circle and the other circle

+moveTo(int newX,int newY):void // * move the center of the circle to the new coordinates

+intersects(Circle other): bool //* returns true if the center of the other circle lies inside this circle else returns false

+resize(double scale):void// * multiply the radius by the scale

+resize(int scale):Circle // * returns a new Circle with the same center as this circle but radius multiplied by scale

+getCount():int //returns the number of circles created

//note that the resize function is an overloaded function. The definitions have different signatures

 

Data file:
0 0 4
0 0 6
- 2 -9 6
4 5 7
7 8 9

 

  1. Extend the driver class to do the following:
    1. Declare a vector of circles
    2. Call a function with signature inputData(vector<Circle> &, string filename) that reads data from a file called dataLab4.txt into the vector. The following c-e are done in this function
    3. 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.
    4. Read the coordinates for the center and the radius from instream to create the circles
    5. 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
    6. Display all the circles in this vector using the toString method
    7. Use an iterator to iterate through the vector to display these circles
    8. Display the count of all the circles in the vector using the getCount method
    9. Display the count of all the circles in the vector using the vector size method
    10. Clear the vector
    11. Create a circle called c using the default constructor
    12. Display the current count of all the circles using the getCount method on c
    13. Display the current count of all the circles using the vector size method

 

  1. Write functions in your main driver cpp file that perform the actions b-l. Your code should be modular and your main program should consist primarily of function calls

 

./main
The circles created are:
(0,0):4
(0,0):6
(-2,-9):6
(4,5):7
(7,8):9
The number of circles, using getCount method is 5
The number of circles, using vetor size method is 5
Erasing the Vector of Circles
Creating a new Circle
The number of circles, using getCount method is 6
The number of circles remaining is 0
Transcribed Image Text:./main The circles created are: (0,0):4 (0,0):6 (-2,-9):6 (4,5):7 (7,8):9 The number of circles, using getCount method is 5 The number of circles, using vetor size method is 5 Erasing the Vector of Circles Creating a new Circle The number of circles, using getCount method is 6 The number of circles remaining is 0
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Class
Learn more about
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.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education