Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 tic tac toe game
Index -> Programming, Java -> Java Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
GA




PostPosted: Sun Mar 19, 2006 10:36 am   Post subject: 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



Tictacktoe2.java
 Description:

Download
 Filename:  Tictacktoe2.java
 Filesize:  14.17 KB
 Downloaded:  578 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
GA




PostPosted: Sun Mar 19, 2006 11:24 am   Post subject: (No subject)

tic tac toe


Tictacktoe2.java
 Description:

Download
 Filename:  Tictacktoe2.java
 Filesize:  14.17 KB
 Downloaded:  260 Time(s)

MysticVegeta




PostPosted: Sun Mar 19, 2006 1:38 pm   Post subject: (No subject)

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:
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 Smile 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
Display posts from previous:   
   Index -> Programming, Java -> Java Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: