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[]);
}
}
It should be:
You just pass
c. You don’t need to indicate it’s an array again.