Given the class Point below, define a class Circle that represents a circle with a given center
Fantastic news! We've Found the answer you've been seeking!
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 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)); } }
Related Book For
Financial Management for Public Health and Not for Profit Organizations
ISBN: 978-0132805667
4th edition
Authors: Steven A. Finkler, Thad Calabrese
Posted Date: