Extend the code from Lab. Use the same UML as below and make extensions as necessary Circle -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     Write a brand new driver program that does the following: Creates a circle object circleOne at (0,0):5. Creates a shared pointer circleOnePtr to circleOne Creates a circle object circleTwo at (-2,-2): 10 Creates a shared pointer circleTwoPtr to circleTwo Use greaterThan to check if circleTwo is bigger than circleOne and display results // **** you will need to change the parameter to shared pointer Declare a vector of pointers to circles- circlePointerVector Call a function with signature inputData(circlePointerVector &, string filename) that reads data from a file called dataLab4.txt into the array The following h-k are done in this function // **** note how the & operator is used in the parameter list 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 of shared 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 You need to go through it and learn how to use shared pointers to objects, create vectors of shared pointers to objects and pass these as parameters. You need to write one line of code. Declare circleTwoPtr. Watch for **** in comments.   Data File: 0 0 4 0 0 12 - 2 -9 11 4 5 7 7 8 9 2 -5 11 the output need to look like screenshot

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

Extend the code from Lab. Use the same UML as below and make extensions as necessary

Circle

-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

 

 

  1. Write a brand new driver program that does the following:
  2. Creates a circle object circleOne at (0,0):5.
  3. Creates a shared pointer circleOnePtr to circleOne
  4. Creates a circle object circleTwo at (-2,-2): 10
  5. Creates a shared pointer circleTwoPtr to circleTwo
  6. Use greaterThan to check if circleTwo is bigger than circleOne and display results // **** you will need to change the parameter to shared pointer
  7. Declare a vector of pointers to circles- circlePointerVector
  8. Call a function with signature inputData(circlePointerVector &, string filename) that reads data from a file called dataLab4.txt into the array The following h-k are done in this function

// **** note how the & operator is used in the parameter list

  1. 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.
  2. Read the coordinates for the center and the radius from instream to create the circles
  3. 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
  4. Display all the circles in this vector of shared pointers using the toString method
  5. Display the sum of the areas of all the circles in the array
  6. Switch the position of the second and fourth circles by swapping pointers to the circles
  7. Display this changed sequence of circles using toString method

You need to go through it and learn how to use shared pointers to objects, create vectors of shared pointers to objects and pass these as parameters.

You need to write one line of code. Declare circleTwoPtr. Watch for **** in comments.

 

Data File:
0 0 4
0 0 12
- 2 -9 11
4 5 7
7 8 9
2 -5 11

the output need to look like screenshot 

In the image displayed, the following information is presented:

- **Analysis Summary:**
  - Circle Two is noted as being larger in size.

- **Circle Details:**
  - Total number of circles given: 6
  - Coordinates and respective sizes (radii) of the circles are:
    - (0,0) with a size of 4
    - (0,0) with a size of 12
    - (-2,-9) with a size of 11
    - (4,5) with a size of 7
    - (7,8) with a size of 9
    - (2,-5) with a size of 11

- **Additional Information:**
  - The total sum of the areas of these circles equals 1671.33 (units not specified).

- **Modified Circle Array:**
  - The circles are reordered (possibility indicating some form of modification or sorting):
    - (0,0) with a size of 4
    - (4,5) with a size of 7
    - (-2,-9) with a size of 11
    - (0,0) with a size of 12
    - (7,8) with a size of 9
    - (2,-5) with a size of 11

This transcription can be utilized for educational purposes, detailing circle properties and presenting data analysis methodologies.
Transcribed Image Text:In the image displayed, the following information is presented: - **Analysis Summary:** - Circle Two is noted as being larger in size. - **Circle Details:** - Total number of circles given: 6 - Coordinates and respective sizes (radii) of the circles are: - (0,0) with a size of 4 - (0,0) with a size of 12 - (-2,-9) with a size of 11 - (4,5) with a size of 7 - (7,8) with a size of 9 - (2,-5) with a size of 11 - **Additional Information:** - The total sum of the areas of these circles equals 1671.33 (units not specified). - **Modified Circle Array:** - The circles are reordered (possibility indicating some form of modification or sorting): - (0,0) with a size of 4 - (4,5) with a size of 7 - (-2,-9) with a size of 11 - (0,0) with a size of 12 - (7,8) with a size of 9 - (2,-5) with a size of 11 This transcription can be utilized for educational purposes, detailing circle properties and presenting data analysis methodologies.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 7 images

Blurred answer
Knowledge Booster
Developing computer interface
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
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