Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Here is the code that is needed: public class Circle { // Student Starter code private double radius; // circle radius /** * Constructor -
Here is the code that is needed:
public class Circle { // Student Starter code
private double radius; // circle radius
/**
* Constructor - Create a new circle
* @param inRadius radius of the circle
*/
public Circle(double inRadius ) {
// implement body here
}
/**
* Return the radius of the circle
* @return radius of the circle
*/
public double getRadius() {
return radius;
}
/**
* set the radius
* @param newRadius new radius of the circle
*/
public void setRadius(double newRadius) {
// implement body here
}
/**
* Compute and return the area of the circle
* @return the area of the circle
*/
public double area() {
return Math.PI * radius * radius;
}
/**
* Stretches circle size by multiplying
* the radius by the factor provided.
* @param factor stretch factor
*/
public void stretchBy(double factor ) {
// implement body here
}
/**
* Return a string representation of a circle.
* @return a string representing this circle
*/
public String toString() {
// implement body here
}
}
public class TestCircle {
public static void main(String [] args) {
// read a radius of the circle from command line
double radius = Double.parseDouble(args[0]);
// Instantiate a Circle object
Circle aCircle = new Circle(radius);
// Print current status of the circle
System.out.println(aCircle);
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started