Results 1 to 10 of 10
Thread: TicTacTo
- 05-08-2009, 12:59 AM #1
Member
- Join Date
- Feb 2009
- Posts
- 13
- Rep Power
- 0
-
What error messages do you see?
edit: Also please post the whole message, and indicate which lines are causing the error.Last edited by Fubarable; 05-08-2009 at 01:33 AM.
- 05-08-2009, 03:11 AM #3
Member
- Join Date
- Feb 2009
- Posts
- 13
- Rep Power
- 0
-
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.Last edited by Fubarable; 05-08-2009 at 03:16 AM.
- 05-08-2009, 03:59 AM #5
Senior Member
- Join Date
- Sep 2008
- Posts
- 564
- Rep Power
- 5
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?Java 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; }
-
I was trying to lead the OP to this conclusion, but I guess not fast enough...
- 05-08-2009, 06:50 AM #7
Member
- Join Date
- Feb 2009
- Posts
- 13
- Rep Power
- 0
Thanks for the replys
Thanks, Didn't notice at first, that if the first IF was true then it would still continue..
Changed to:
Java 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 #8
Senior Member
- Join Date
- Sep 2008
- Posts
- 564
- Rep Power
- 5
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.
-
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 #10
Senior Member
- Join Date
- Mar 2009
- Posts
- 552
- Rep Power
- 5


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks