Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MO 5 LabB You can download the Lab 5 B Document Here i, Requirements: Make sure you read the introduction to GOP Example document and

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed
MO 5 LabB You can download the Lab 5 B Document Here i, Requirements: Make sure you read the \"introduction to GOP Example\" document and the required textbook reading before attempting this lab. in addition there are there are several sample programs that are provided in your resources unit that will have helpful tips for understanding how to use features that are needed in this lab. Make sure you have completed Lab 4, Lab 5A and Programming Assignment 3. You will be using the same Circle class, but this time, creating a completely new driver. We will dive into creating pointers to Circle objects, creating an array of pointers to Circle objects and use the * and -> operators to access values inside class member variables. Swapping pointers is another practice, getting ready for more complex search and sort algorithms in the second half of the course. You will be given a class shell and a driver shell with declarations to help you get started. Specications: Extend the code from LabSA. 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 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*^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 scalesignatures THIS LAB USES POINTERS 1. Write a brand new driver program that does the following: 2. Creates a circle object circleOne at (0,0):5. 3. Creates a pointer c1Ptr to circleOne 4. Creates a circle object circleTwo at (-2,-2): 10 5. Creates a pointer c2Ptr to circleTwo 6. Use greaterThan to check if circleTwo is bigger than circleOne and display results 7. Declare an array of pointers to circles- circlePointerArray 8. Call a function with signature inputData(circlePointerArray, string filename) that reads data from a file called dataLab5.txt into the array The following h-k are done in this function 9. Use istringstream to create an input string stream called instream. Initialize it with each string that is read from th data file using the getline method 10. Read the coordinates for the center and the radius from instream to create the circles 11. 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 12. Display all the circles in this array of pointers using the toString method 13. Display the sum of the areas of all the circles in the array 14. Switch the position of the second and fourth circles by swapping pointers to the circles 15. Display this changed sequence of circles using toString method Here is some Starter Code that you can download + int main(){ // #include // for accessing memory dynamically from the heap// Note the use of -> Testing and Verification Test your program thoroughly. Make sure that it compiles and runs correctly. I will be inspecting your code to make sure that it addresses the prompt correctly. So it is not sufficient for you to demonstrate that the output matches the required one. Your output needs to look like this Circle Two is bigger The total number of circles is 6 They are : (0, 0) :4 (0, 0) :12 (-2,-9) :11 (4, 5) :7 (7,8) :9 (2,-5) :11 The total sum of the areas is 1671.33 The modified array is (0, 0) :4 (4,5) :7 (-2,-9) :11 (0, 0) :12 (7, 8):9 (2,-5) :11 Submission Guidelines 1. Zip your all the above three files into a file called wxxxxxxx_Lab5B.zip. xxxxxxx is your 7 digit student id. For example if your wid is w3691234 then your file would be called w3691234_Lab5B.zip. Failure to do this will result in your assignment NOT being graded 2. Submit a screenshot in a doc file showing that your program has the above output. Name this file WXXXXXXXLab5B.docx. Do not zip this file with the code file

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions