Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C++ Linux need help woth this code, a little confused with it. if someone could add some comments to their code rhat would be helpful
C++
- radius: a double - pi: a double initialized with the value 3.141592653589793. The class should have the following member functions: - Default Constructor: A default constructor that sets radius to 0.0. - Constructor: Accepts the radius of the circle as an argument. - setRadius: A mutator function for the radius variable. - getRadius: An accessor function for the radius variable. - getArea: Returns the area of the circle, A=r2. - getDiameter: Returns the diameter of the circle, which is twice the radius. - getCircumference: Returns the circumference of the circle, C=2r. Write a program that demonstrates the Circle class by asking the user for the circle's radius, creating a Circle object, and then reporting the circle's area, diameter, and circumference. Also create a makefile for the program. Validation: Make sure that the value of the radius is not negative, if it is have the class reset it to 0 . Do the validation in the class implementation, not in the main. 1. Update the circle class that you did in the in-lab exercise to include member variables, x and y which represent the center of the circle. Also create the following new member functions. - Constructor: Accepts the center, x and y, and the radius of the circle as arguments. - setCenter: A mutator function to set the center of the circle. - getCenterX: An accessor function for the x coordinate of the center. - getCenterY: An accessor function for the y coordinate of the center. - collide: A function that will take as a parameter a circle and determine if the two circles are colliding. Two circles will collide if the distance between their centers is less than or equal to the sum of there radii. The function should return a boolean. Write a program that demonstrates the new Circle class by having the program generate an array of 1000 random circles each with radii between 1 and 2 , and centers with x and y coordinates between 20 and 20 . Have the program find and report every pair of circles that collide Linux
need help woth this code, a little confused with it. if someone could add some comments to their code rhat would be helpful too. Thank you!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started