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     A. 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 3-5 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 -> Erase all circles which have a radius greater than 8 -> Display the number of circles remaining using vector size method -> Display all the circles remaining using toString() -> create Circle object circle1 at (3,4) and radius 7 -> create a Circle object circle2 at (-2,-4) and radius 4 -> insert these circles into the vector at positions 2 and 3 respectively -> Display the vector of circles -> Write a simple destructor in the Circle.cpp class that simple displays     “In Destructor”   B. Write functions in your main driver cpp file that perform the actions 10-17 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

 

 

A. 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 3-5 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. -> Erase all circles which have a radius greater than 8
  11. -> Display the number of circles remaining using vector size method
  12. -> Display all the circles remaining using toString()
  13. -> create Circle object circle1 at (3,4) and radius 7
  14. -> create a Circle object circle2 at (-2,-4) and radius 4
  15. -> insert these circles into the vector at positions 2 and 3 respectively
  16. -> Display the vector of circles
  17. -> Write a simple destructor in the Circle.cpp class that simple displays

    “In Destructor”

 

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

 

 

 

Inside Destructor
Inside Destructor
Inside Destructor
Inside Destructor
Inside Destructor
Inside Destructor
Inside Destructor
Inside Destructor
Inside Destructor
Inside Destructor
Inside Destructor
Inside Destructor
Inside Destructor
The circles created are:
(0,0):4
(0,0):12
(-2,-9):11
(4,5):7
(7,8):9
(2,-5):11
The number of circles, using getCount method is 6
The number of circles, using vetor size method is 6
Your output with the destructor message needs to look like this. The number of destructor message will
vary depending on the location of memory release in your code
Inside Destructor
Inside Destructor
Inside Destructor
Inside Destructor
The number of circles remaining is 2
The circles left are :
(0,0):4
(4,5):7
Inside Destructor
Inside Destructor
The circles vector now has these circles :
(0,0):4
(3,4):7
(-2,-4):4
(4,5):7
Inside Destructor
Inside Destructor
Inside Destructor
Inside Destructor
Inside Destructor
Inside Destructor
Transcribed Image Text:Inside Destructor Inside Destructor Inside Destructor Inside Destructor Inside Destructor Inside Destructor Inside Destructor Inside Destructor Inside Destructor Inside Destructor Inside Destructor Inside Destructor Inside Destructor The circles created are: (0,0):4 (0,0):12 (-2,-9):11 (4,5):7 (7,8):9 (2,-5):11 The number of circles, using getCount method is 6 The number of circles, using vetor size method is 6 Your output with the destructor message needs to look like this. The number of destructor message will vary depending on the location of memory release in your code Inside Destructor Inside Destructor Inside Destructor Inside Destructor The number of circles remaining is 2 The circles left are : (0,0):4 (4,5):7 Inside Destructor Inside Destructor The circles vector now has these circles : (0,0):4 (3,4):7 (-2,-4):4 (4,5):7 Inside Destructor Inside Destructor Inside Destructor Inside Destructor Inside Destructor Inside Destructor
Expert Solution
trending now

Trending now

This is a popular 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