Reputation: 103
Novice programmer here. trying to learn static methods and recursion. No idea why I keep getting ".class expected" error whenever i try to call "drawCircle()". My code is below. Help plz? Thanks!
public class Drawliin
{
public static void drawCircle(int numberOfTimes, double radius, double center[])
{
int rep = 1;
if (rep == 1)
{
StdDraw.circle(center[0], center[1], radius);
rep++;
}
else if (rep <= numberOfTimes)
{
StdDraw.circle(center[0 + radius], center[1], radius);
StdDraw.circle(center[0 - radius], center[1], radius);
StdDraw.circle(center[0], center[1 + radius], radius);
StdDraw.circle(center[0], center[1 - radius], radius);
rep++;
drawCircle(numberOfTimes, radius, center[]);
}
}
public static void main(String[] args)
{
int N = Integer.parseInt(args[0]);
double r = Double.parseDouble(args[1]);
StdDraw.setXscale(-10, 10);
StdDraw.setYscale(-10, 10);
double c[] = new double[2];
drawCircle(N, r, c[]);
}
}
Upvotes: 0
Views: 1260
Reputation: 1979
Your problem is at these lines:
drawCircle(N, r, c[]);
drawCircle(numberOfTimes, radius, center[]);
they should be:
drawCircle(N, r, c);
drawCircle(numberOfTimes, radius, center);
You don't need to define it as an array again, you did that in the parameters. Just pass the arguments to the function.
Upvotes: 1
Reputation: 4653
Remove the braces in 'center' and 'c:
drawCircle(numberOfTimes, radius, center);
drawCircle(N, r, c);
Upvotes: 0
Reputation: 284937
It should be:
drawCircle(N, r, c);
You just pass c
. You don't need to indicate it's an array again.
Upvotes: 5