Question: home / study / questions and answers / engineering / computer science / define a class named circle. a circle object stores ... Question write
home / study / questions and answers / engineering / computer science / define a class named circle. a circle object stores ...
Question
write a java class named Circle. A Circle object stores a radius and the (x,y) coordinates of its center point. Each Circle object should have 3 private fields , x-coordinate, y-coordinate and radius. Each circle object should have the following public methods:
Circle(x,y,radius)
Constructs a new circle with a center specified by the given Point and with the given integer radius.
getX()
returns the center's x coordinate
getY()
returns the center's y coordinate
getRadius()
returns the circle's radius
getArea()
Returns the area occupied by the circle, using the formula (pie)*r^2
getCircumference ()
Returns the circle's circumference (distance around the circle) using the formula 2(pie)(r)
toString()
Returns a string representation of the circle,such as"Circle[center = (75,20),radius=30]"
contains(x,y)
Returns true if the (x,y) coordinates lie within the circle else returns false. (Hint:calculate the distance between the center and the (x,y) and compare it with the radius)
Then write a client class named CircleClient. It should create an object of class Circle and initialize it to (10.5) and Radius to 7. Print the object Print out its circumference and area. If point(5,7) lies within the clircle print " (5,7) lies within the circle"else print"(5,7) doesnot lie within the circle".
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
