for(int r =0; r < cells.length; r++){//I can get the other game boards to print if I take out: [0]for(int c =0; c < cells[r].length; c++){// and [1]

If it works and you'd like me to explain it, let me know.

August 30th, 2013, 04:43 PM

NickieBoren

Re: Problem with Multi-Dimensional Arrays

That was the first thing I tried and I get rows = columns. So the 6x7 Connect Four board comes out 6x6.

August 30th, 2013, 05:10 PM

GregBrannon

Re: Problem with Multi-Dimensional Arrays

It was a guess, because the code you had there was suspect, but I can't do better because you haven't given us code that we can run (missing something called 'Mark' and maybe others), and you haven't explained your problem very well.

Quote:

That was the first thing I tried . . .

That's not what your post said. You said you took out the [0] and the [1]. It's important that you take out the [0] and replace the [1] with an [r].

As the error message says, if you're creating a board of 6 rows by 7 columns, the max index for rows should be 5 and for columns 6. The code I suggested should work for all board dimensions.

If you want help with an error message, copy and paste the error message into your post EXACTLY as it appears at your end, and point to the line numbers it refers to in code you've posted. Don't interpret or excerpt it.

In various places (before Board(), after Board(), before and after each line in Board()) and it prints out the correct numbers of array size (3x3, 6x7, 5x8), but the end game boards do not print with these sizes.

When I run these corrections, I don't get any errors, but my arrays are 3x3 (Tic Tac Toe), 6x6 (Connect Four) instead of 6x7 and 5x5 (Mastermind) instead of 5x8.

My question is: How do I get my arrays to print out the correct sizes? = 3x3, 6x7, and 5x8

August 30th, 2013, 06:26 PM

GregBrannon

Re: Problem with Multi-Dimensional Arrays

Did you try the change I suggested? I've tried it, and it works fine IF you correct both the Board() constructor AND the toString() method.