Create a program that has the following classes: Point - Just like in the lecture, with attributes x and y set to 0 by default. Circle - Contains two attributes, center and radius. center is of type Point defined above (initialize a Point instance for this), while radius is set to 0 by default. The program must have the function point_in_circle(c, p) where c is a Circle and p is a Point. The function returns True if the point is within the circle, and False otherwise. You may use the math module (and nothing else) if necessary. You may also create other functions that can help you code the main function much easier. Example usage

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter11: Inheritance And Composition
Section: Chapter Questions
Problem 6PE
icon
Related questions
Question

Create a program that has the following classes:

  • Point - Just like in the lecture, with attributes x and y set to 0 by default.
  • Circle - Contains two attributes, center and radius. center is of type Point defined above (initialize a Point instance for this), while radius is set to 0 by default.

The program must have the function point_in_circle(c, p) where c is a Circle and p is a Point. The function returns True if the point is within the circle, and False otherwise.

You may use the math module (and nothing else) if necessary. You may also create other functions that can help you code the main function much easier.

Example usage

 
# Initialize a circle with center at (0, 0) and radius 1 (unit circle).
c = Circle()
c.center.x, c.center.y, c.radius = 0, 0, 1
 
# Initialize a point located at (1, 1)
p = Point()
p.x, p.y = 1, 1
 
# This returns False since (1, 1) is outside the circle
point_in_circle(c, p)
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Class
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
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,