Question: In this assignment you will implement a class with attributes ( aka data fields ) and methods. Follow these guidelines ( in Java ) :

In this assignment you will implement a class with attributes (aka data fields) and methods. Follow these guidelines (in Java):
1. Name the class MyCircle
2. Declare 3 private double properties named x, y, and radius. The x and y attributes represent the center of the circle, and the radius defines the radius of the same circle object.
3. Implement 3 constructors:
i. The default constructor creates a circle object center at (0,0) and has radius 1.
ii. Overloaded constructor that accepts 1 double argument used to define a circle's radius, and default center at (0,0).
iii. Overloaded constructor that accepts 2 double arguments to define the center point coordinates, and sets the radius to the default 1 value.
iv. Overloaded constructor that accepts 3 double arguments that initializes the center point coordinates and the radius of the circle object with the given values, the arguments should be in this order: x, y, radius respectively.
4. Implement getter methods for each of the private data fields.
5. Implement setter methods for each of the private data fields.
6. Implement the contains(doubnle x, double y) method. It returns true if the given (x,y) arguments are inside the circle object, false otherwise.
7. Make sure that the radius property of the circle can never be less than or equal to 0(zero).
i. In the constructor(s), make sure that if the given radius value is less than or equal to 0, that it sets radius to the default value instead (1).
ii. In the radius setter, make sure the value does NOT change if the given value is 0 or negative.
Boilerplate code:
public class MyCircle {
/* Attributes/Data fields/Properties */
// YOUR CODE HERE
/* Constructor(s)*/
Circle (){
// YOUR CODE HERE
}
Circle (/* add expected arguments here if needed */){
// YOUR CODE HERE
}
Circle (/* add expected arguments here if needed */){
// YOUR CODE HERE
}
Circle (/* add expected arguments here if needed */){
// YOUR CODE HERE
}
/* Method(s)*/
// Getters and Setters
public /* add appropriate return type */ setRadius(/* add expected arguments here if needed */){
// YOUR CODE HERE
}
public /* add appropriate return type */ getRadius(/* add expected arguments here if needed */){
// YOUR CODE HERE
}
public /* add appropriate return type */ setX(/* add expected arguments here if needed */){
// YOUR CODE HERE
}
public /* add appropriate return type */ getX(/* add expected arguments here if needed */){
// YOUR CODE HERE
}
public /* add appropriate return type */ setY(/* add expected arguments here if needed */){
// YOUR CODE HERE
}
public /* add appropriate return type */ getY(/* add expected arguments here if needed */){
// YOUR CODE HERE
}
// Other helpful methods
public /* add appropriate return type */ contains(double x, double y){
// YOUR CODE HERE
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!