Help with Checkerboard GraphicsProgram (Due Tomorrow!)
import acm.graphics.*;
import acm.program.*;
import java.awt.*;
public class Checkers extends GraphicsProgram {
public void run() {
double sqSize = (double) getHeight() / N_ROWS;
for (int i = 0; i < N_ROWS; i++) {
for (int j = 0; j < N_COLUMNS; j++) {
double x = j * sqSize;
double y = i * sqSize;
GRect sq = new GRect(x, y, sqSize, sqSize);
sq.setFilled((i + j) % 2 != 0);
sq.setColor(Color.GRAY);
add(sq);
for (i=0;i<rows;i++) {
if (i>3 and i<6) continue; //says there is a parentheses error here?
for j=0;j<cols;j++ {
if (i+j %2 =0) addchecker()
}
}
void addchecker()
{
}
}
}
}
private static final int N_ROWS = 8;
private static final int N_COLUMNS = 8;
}
What do you all think is wrong with it? The overall goal of this program is to place black and red checkers on the checkerboard. Checkers are to be added only in rows 1, 2, 3, 6, 7 and 8. So if using loops, this corresponds to i = 0,1,2,5,6 and 7 (i representing the row number). What would be a good switch-statement to write for this?? Btw, first three rows (top) should be red, and last three (bottom) should be black. Possibly an if statement here?
One more thing, how do I center my checkerboard in the window?
Re: Help with Checkerboard GraphicsProgram (Due Tomorrow!)
Quote:
What do you all think is wrong with it?
One problem is that the addchecker method doesn't do anything.
Please copy and paste here all of the error messages you are getting.
Re: Help with Checkerboard GraphicsProgram (Due Tomorrow!)
Suggested reading:
http://www.javaprogrammingforums.com...e-posting.html
How To Ask Questions The Smart Way
And this is your second post that you have labeled 'due tomorrow' with an exclamation point. I suggest you read the section in the above link regarding marking threads as urgent - statements such as this often cause contributors to avoid such posts
Re: Help with Checkerboard GraphicsProgram (Due Tomorrow!)