Java - adding 9 boxes to the main block

Typical newb here. Trying to build an entire powerful tic-tac-toe grid for my first programming class.

I tried everything that makes sense to do this from the api documentation, but so far no luck.

I think my biggest problem is that you don’t understand how to use methods and parameters and be a beginner, but I will get there.

This is what I have:

import java.awt.Rectangle;

public class TicTacToe {
    public static void main (String[] args) {
        new Rectangle (0,0,30,30); //create new box
        Rectangle box = new Rectangle (0,0,30,30); // tying the box to a variable

        box.add (Rectangle 0,0,10,10); /* error box can onot be resolved to a variable*/

    }
}

So my question is, how do I add 9 drawers 10 wide 10 wide to this larger box? When I add these boxes, do I need to enter new xy values ​​too?

Thanks for the help!

+5
source share
1 answer

, , , . ? , . tic tac toe 9 , 9 , 3 : 1) X, 2), O 3). , , , 9 .

:

int[] board = new int[9];

, :

static final int OPEN = 0;
static final int FILLED_WITH_X = 1;
static final int FILLED_WITH_O = 2;

, ( ) . .

, Rectangle, - . . 9 , , . , x o ( ) board. , , . (4 ) , , , .

+2

All Articles