Question: 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

1 Expert Approved Answer
Step: 1 Unlock

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... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!