Question
Need Help! To start, you are required to implement the method called nestedCircle() recursively, which gets 6 input parameters and return a string. This method
Need Help! To start, you are required to implement the method called nestedCircle() recursively, which gets 6 input parameters and return a string. This method keeps drawing circles with the same center and different radius until the radius gets negative. The output of the method is a list of all the circles radius from the most outer to the most inner one. Please see the javaDoc of this method for more information. Sample Call: PE1.nestedCircle (0.5, 0.5, 0.4, 0.05, blankCanvas, "") Corresponding Output: [0.4, 0.35, 0.3, 0.25, 0.2, 0.15, 0.1, 0.05, 0.0]
Please see code below:
/**
* This method draws a number of circles that share the same center, as long as the radius is positive.
* @param x is the x-coordinate of the circles
* @param y is the y-coordinate of the circles.
* @param radius is the radius of a circle.
* The function is called with the radius that is cut to two decimal points.
* For example 0.39876543210 must be cut to 0.39
* @param diff is the difference between the radius of a circle and its immediate inner circle.
* @param page is the canvas on which the circles are drawn.
* @param radiusList is an accumulated list of the radius of the circles that were drawn.
* @return a list of all the circles' radius that were drawn.
*/
public static String nestedCircle (double x, double y, double radius, double diff, Draw page, String radiusList) {
// your code goes here.
return "";
}
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