Having Trouble with this problem, Any help is appreciated! Define a class named
ID: 3725544 • Letter: H
Question
Having Trouble with this problem,
Any help is appreciated!
Define a class named Circle. A circle object stores a radius and the (x, y) coordinates of its center point. Each Circle object should have the following public methods . Circle (center, radius) Constructs a new circle with a center specified by the given Point and with the given integer radius. . getCenter Returns the circle's center Point. getRadius () Returns the circle's radius getArea ) Returns the area occupied by the circle, using the formula . getcircumference ) Returns the circle's circumference (distance around the circle), using the formula 2Ttr . toString ) Returns a string representation of the circle, such as "Circle[center- (75, 20), radius-30]". e draw (g) Draws the circle onto a DrawingPanel contains (p) Returns whether the given point lies inside the circleExplanation / Answer
public class Point{ private double x; private double y; public Point() { } public Point(double x, double y) { this.x = x; this.y = y; } public double getX() { return x; } public void setX(double x) { this.x = x; } public double getY() { return y; } public void setY(double y) { this.y = y; } } public class Circle { private Point center; private double radius; public Circle(Point center, double radius) { this.center = center; this.radius = radius; } public Point getCenter() { return center; } public double getRadius() { return radius; } public double getArea() { return Math.PI * radius * radius; } public double getCircumference() { return 2 * Math.PI * radius; } @Override public String toString() { return "Circle[" + "center=(" + center.getX() + ", " + center.getY() + "), radius=" + radius + ']'; } }
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.