I wrote this code for a small project, and I am probably declaring a method in a method, because I keep getting "illegal start of an expression." This is happening at line 27, and 43. I am fairly new to java, so please don't be to harsh. I might have more errors in this code than I think. Thanks
// Loop with methods project
import acm.program.*;
import acm.graphics.*;
import java.awt.*;
public class MethodProject extends GraphicsProgram
{
public static void main(String [] args) {new MethodProject().start(args);};
public void run( )
{
singleLoop(0,0,10,20,30,40, Color.BLUE, Color.GREEN); //Controls placement, size, color
doubleLoop(50,50,100,100,15,1);
whileLoop(100,100, 0,70, 150, 200, Color.BLUE, Color.YELLOW);
}
public void singleLoop(int x, int y, int n, int sz, int dx, int dy, Color b, Color c)
{
for (int x = 0; x <= 0; ball.move(1,1)) {
GOval ball = new GOval(sz, sz);
ball.setColor(b);
ball.setFilled(true);
add(ball,x,y);
setBackground(Color.c);
removeAll();
pause(10000);
}
public void doubleLoop(int x, int y, int n, int sz, int dx, int dy)
{
for (int x = 0; x < 700; x = x + dx) {
for (int y = 0; y < 700; y = y + dy) {
GRect rect = new GRect(x, y, sz, sz);
rect.setFilled(true);
ball.setColor(Color.RED);
add(rect);
pause(50);
setBackground(Color.BLUE);
removeAll();
pause(10000);
}
public void whileLoop(int x, int y, int n, int sz, Color c, Color d)
{
n = 0;
GOval ball2 = new GOval(x, y, sz, sz);
ball2.setFilled(true);
ball2.setColor(Color.d);
add(ball);
GOval ball3 = new GOval(y,x, sz, sz);
ball3.setColor(Color.c);
ball3.setFilled(true);
add(ball3);
while (n < 20) {
ball2.move(4,4);
ball3.move(-4,4);
pause(30);
n++;
}
}
}
}
}
}