![]() |
tic tac toe - Printable Version +- Sinisterly (https://sinister.ly) +-- Forum: Coding (https://sinister.ly/Forum-Coding) +--- Forum: Java, JVM, & JRE (https://sinister.ly/Forum-Java-JVM-JRE) +--- Thread: tic tac toe (/Thread-tic-tac-toe) |
tic tac toe - blackeagle - 11-12-2013 few days ago i saw @Ex094 working on making a tic tac toe game in c i found it interesting and it will be a good challenge for me so i started working on that project !! as every1 helped me on my first project rock scissors paper game and gave me feedbacks to make it better i wish you could do the same here !! first i'll share with you my code i'm stuck somewhere couldn't figure out a way to do it so you guys could start by helping me solving this problem then giving me advices on how to make my code better!! Spoiler: ok so as you can see in my main it keeps asking to choose a box until the counter is equal or bigger then 9 or we have a winner!! what i want to do is after the do while is over if we have a winner i wanted to say the winner is player 1 if player 1 won or the winner is player 2 if player 2 won and finally it's a tie if no1 won !! can u give me ideas on how to do it ? thx in advance for the help ![]() RE: tic tac toe - Ex094 - 11-12-2013 I think the CheckWin part can be done in a more clear way using Java, Do some searches on Google and I'm sure you'll find it. RE: tic tac toe - blackeagle - 11-12-2013 i'll work on this later but first i need a little help to be able to finish my code !! RE: tic tac toe - Deque - 11-13-2013 Quote:what i want to do is after the do while is over if we have a winner i wanted to say the winner is player 1 if player 1 won or the winner is player 2 if player 2 won and finally it's a tie if no1 won !! Instead of returning a boolean let the checkWin return who won. Look into Enums: http://docs.oracle.com/javase/tutorial/java/javaOO/enum.html Then create an enum type that has the values: PLAYER1, PLAYER2, NO_WINNER Then you will say something like: Code: while ((counter < 9) && (checkWin(board) == NO_WINNER)); |