
-----------------------------------
GA
Sun Mar 19, 2006 10:36 am

tic tac toe game
-----------------------------------
hey

i know its not great, but i've only been programming java for a month and just wanted to know what u think

-----------------------------------
GA
Sun Mar 19, 2006 11:24 am


-----------------------------------
tic tac toe

-----------------------------------
MysticVegeta
Sun Mar 19, 2006 1:38 pm


-----------------------------------
good pretty good for 1 month of programming. I would suggest:
- Use loops for checking who wins instead of "if" because take a look at the following code:
for (int i =0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
if (your2DArray[i][j] != "X") return false;
}
}
return true;

You have just checked diagonally, but using the same loop you can check the inverse diagonal :wink:
And then you would need just 2 more loops, 1 of them for 2 horizontals, 1 of them for 2 verticals. What the code does is checks for "X"s. if the string is not "X" then it returns false because they are not in a row :) You can put al the cehcks in the same method and use it to check for both X and 0's. It will save you a lot of code. 

- Error trapping, a char or string crahes the program
