Write a simple class named circle, with a single instance variable: a double named x, y and radius. Use GUI components to read any input used to initialize your circles (x, y, r). Your class should have member functions with the following signatures.
- void setRadius(double r)
- void setX(double value)
- void setY(double value)
- double getRadius()
- double getX()
- double getY()
- double getArea()
- bool containsPoint(double xValue, double yValue)
When you are calculating the area you can use 3.14 for pi.
The formula will be radius * radius * 3.14.
You can determine whether or not a point is in a circle by calculating the distance from the center of the circle (its x and y coordinates) to the point. If this distance is less than or equal to the radius then the point is inside the circle. (
calculate distance between two points
)
Write a main function that tests your class. It should instantiate a number of circle objects with different radius values. It should report any results using GUI components. You should test all three member functions until you are confident that they work. For practice, make sure you try each of the following:
- Create a local circle object and set its x, y, and radius. Verify that it’s area is calculated correctly.
- Create a circle reference variable, and point it at a dynamically instantiated circle. Use the pointer to set it’s x, y, and radius values
- Create a local array of three circles. Test the member functions on one of the elements.
- Dynamically instantiate an array of three circles. Test the member functions on one of the elements.