[hotjoe.com] HotJoe Java Help Forums
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Visit java.com
Please send email if you are having login problems - see the posts below for more info.
Hotmail and Yahoo! users - please see the Hotmail post or the Yahoo! post for information on lost emails.
TICTACTOE HELP!  XML
Forum Index » Java Programming
Author Message
nueva

Newbie

Joined: 08/08/2008 21:22:42
Messages: 2
Offline

Hi, I am not sure how to create the GUI like as follows:


| |
--------------
| |
--------------
| |


and when a person inputs row 1 column 1 , it should come out as

X | |
--------------
| |
--------------
| |


but instead my code for the GUI only runs as

X


how to make and show the gameBoard at every time the user plays??



stdunbar

Newbie
[Avatar]

Joined: 06/22/2005 14:51:37
Messages: 849
Location: Superior, CO, USA
Offline

Can you let us know where you're stuck? You question comes across as "how do I write this?". We'll be glad to help if you get stuck somewhere.

Thanks for using the forums at hotjoe.com
[WWW] [Yahoo!] [ICQ]
nueva

Newbie

Joined: 08/08/2008 21:22:42
Messages: 2
Offline

Sorry about that...actually im done with the tic tac toe code... however im not sure how to make the game a draw... i have initialized the code for method namned checkwinner() whereby it checks the 2d array like for e.g.

// check vertically
if (board[0][i]==(board[1][i]) &&
board[0][i]==(board[2][i]))
{
if (board[0][i]!=(dashes))
{
return board[0][i];
}
}
}



and I have done that for horizontal and for diagonal. How the program is suppose to know if there is no winner? And the fact that the 2d aray has been used up by 'X's and 'O's already? Do i use If else method? how ?
tfecw

Newbie

Joined: 09/19/2005 15:02:20
Messages: 144
Location: No. VA.
Offline

It seems to me that there is no winner when there are no 3 X's or O's in a row (which you've done) and when the number of moves is over 9.

Also, I think you've done the hardest part of drawing the board and that's modeling the actual board in some data structure.

Now you just need to print everything out.
Since you're just getting started, i'd start out slow. For the first pass, i would just print out the 2d array you're using so it looks like:

X X X
O O O
X X X

the X's and Os won't always look like that, but i think you get the point. Once you get that far, i'd start adding in the rest of the lay out. Adding the 2
rows of '---' where they belong. Once you get that far, then add in the '|' where they go.

If you still have trouble, let us know and post what you've gotten so far.
aim icon
 
Forum Index » Java Programming
Go to:   
Powered by JForum 2.1.9 © JForum Team
This site run by Scott Dunbar of Xigole Systems. © 2005-2011 - Scott Dunbar
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners
hotjoe.com, xigole.com, and Scott Dunbar have no affiliation with Oracle