Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is C++ :D In this Assignment, we will use Programming OO Design of Separation between the Specification (file.h) and Implementation (file.cpp) Write class named

This is C++ :D

In this Assignment, we will use Programming OO Design of Separation between the Specification (file.h) and Implementation (file.cpp)

Write class named Circle, with three private variables: doubles named x, y and radius. The center of the circle is denoted by coordinates (x,y), and the radius of the circle is denoted by radius. It should have public 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)

The first six member functions are straightforward functions to set and get the private member variables.

double getArea()

This member function should return the area of the circle. When you are calculating the area you can use 3.14 for pi. The formula is radius * radius * pi. bool containsPoint(double xValue, double yValue)

This member function should return true if the point at (xValue, yValue) is contained in the circle, and false if not. 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 (parameters xValue, yValue). If this distance is less than or equal to the radius then the point is inside the circle. For your reference, here is how to calculate distance between two points.

For example, let's say we have instantiated a Circle object named myCircle which has x=2.0, y=3.0, and radius=2.0.

myCircle.containsPoint(2.0, 4.0) should return true because (2.0, 4.0) is contained in myCircle.

myCircle.containsPoint(2.0, 10.0) should return false because (2.0, 10.0) is not contained in myCircle.

Write a main function that tests your class. It should instantiate a number of circle objects with different radius values and centers. You should test all your member functions. At minimum, make sure you try each of the following and provide sample output for each:

Create a local circle object and set its x, y, and radius. Verify that its area is calculated correctly.

Create a circle pointer, and point it at your local circle object. Use this pointer to set its x, y, and radius values to new values.

Using your pointer, verify that your containsPoint() function works by trying a point which is in fact in your circle, and showing it returns true. Also, try a different point which is not in your circle and show it returns false.

Implement the Circle class in separate .h and .cpp files. Circle.h contains your class declaration and Circle.cpp contains your class implementation.

Could you please be kind enough and show me the screenshot of your code by using Visual Studio and type the code?

Thank you so much for reading this and have a good one!

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

Modern Datalog Engines In Databases

Authors: Bas Ketsman ,Paraschos Koutris

1st Edition

1638280428, 978-1638280422

More Books

Students also viewed these Databases questions