# TicTacTo

• 05-08-2009, 12:59 AM
Blacknight
[Solved]TicTacTo
Problem solved.
• 05-08-2009, 01:24 AM
Fubarable
What error messages do you see?

edit: Also please post the whole message, and indicate which lines are causing the error.
• 05-08-2009, 03:11 AM
Blacknight
Quote:

Originally Posted by Fubarable
What error messages do you see?

edit: Also please post the whole message, and indicate which lines are causing the error.

http:/img7.imageshack.us/img7/8339/errorvit.png
• 05-08-2009, 03:13 AM
Fubarable
So you're getting an arrayindexoutofbounds error where you're using a -1 as the array index. However you still haven't told us what line is causing the error, and only you will know as the line numbers in the error correlate with the lines as they exist in your exact code. Please help us help you.

Also from the error we know that somewhere you're setting an array index to -1. If you walk through your code using the line that causes the error as a reference point, you should see where you're doing this, and then with thought and perseverance, figure out why. You may wish to restart this project but first plan out just what you want your code to do and how it does it on paper. Your program will be much more organized and easier to debug if done this way. Best of luck.
• 05-08-2009, 03:59 AM
emceenugget
Code:

```while (a != -1) { // Check for winner(Not Complete)                 if (Column1[a] == -1) {                         a = -1;                 }                 if (Column2[a] == -1) {                         a = -1;                 }                 if (Column3[a] == -1) {                         a = -1;                 }                                 if (a == 2) {                         GameOver = true;                 }                                 a = a + 1;         }```
this is the culprit code. you're deliberately accessing array index of -1 over and over and over again. i'm sure you know what you really wanna do with it?
• 05-08-2009, 04:13 AM
Fubarable
I was trying to lead the OP to this conclusion, but I guess not fast enough...
• 05-08-2009, 06:50 AM
Blacknight
Quote:

Originally Posted by emceenugget
Code:

```while (a != -1) { // Check for winner(Not Complete)                 if (Column1[a] == -1) {                         a = -1;                 }                 if (Column2[a] == -1) {                         a = -1;                 }                 if (Column3[a] == -1) {                         a = -1;                 }                                 if (a == 2) {                         GameOver = true;                 }                                 a = a + 1;         }```
this is the culprit code. you're deliberately accessing array index of -1 over and over and over again. i'm sure you know what you really wanna do with it?

Thanks, Didn't notice at first, that if the first IF was true then it would still continue..

Changed to:

Code:

```        int i = 0;         boolean Done = false;         while (Done == false) { // Check if there's a winner, IF not continue.                 if (Column1[i] == -1 || Column2[i] == -1 || Column3[i] == -1)                 {                         Done = true;                 }                 if (i == 2) {                         GameOver = true;                         Done = true;                 }                                 i++;         }```
• 05-08-2009, 09:36 PM
emceenugget
well my purpose for going a little deeper is cuz there's a lot of people who can't take subtle hints and get angry lately (the majority of my responses). that, and there are also a lot of people who would still take advice like i gave and still say "what's that supposed to mean" (see the "illigel" expression topic). thankfully, this was not one of those people.
• 05-08-2009, 11:18 PM
Fubarable
true you're right. Also, the nature of communication here is a bit slow at times to have a dialog.
• 05-09-2009, 12:05 AM
Singing Boyo