Given the class Point below, define a class Circle that represents a circle with a given center and radius. The Circle class should have an
Given the class Point below, define a class Circle that represents a circle with a given center and radius. The Circle class should have an attribute named center as well as an integer radius attribute. The center is a point object, defined by the class Point. The class should also have these members:
- the constructor of the class, which should take parameters to initialize all attributes
- a getter for each instance data
- a setter for each instance data
- an equals method that returns true if two circles have same radii and false otherwise
- an area() method that returns the area of the circle
- a toString() method that returns the summary of a Circle object
public class Point{ private int x, y; public Point(int newX, int newY){ x = newX; y = newY; } public String toString(){ return "x:"+x+","+"y:"+y; } public double distance(Point other){ return Math.sqrt(Math.pow(x-other.x,2)+Math.pow(y-other.y,2)); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Below is the Python implementation of the Circle class which uses the given Point class as its center I will mirror the functionality and follow Pytho...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