Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals, Design, and Implementation

Authors: David M. Kroenke, David J. Auer

14th edition

133876705, 9781292107639, 1292107634, 978-0133876703

More Books

Students also viewed these Databases questions

Question

What does Processing of an OLAP Cube accomplish?

Answered: 1 week ago