| Author |
Message |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 08/08/2008 21:39:36
|
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??
|
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 08/11/2008 14:57:29
|
stdunbar
Newbie
![[Avatar]](/images/avatar/a87ff679a2f3e71d9181a67b7542122c.png)
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 |
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 08/11/2008 23:20:57
|
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 ?
|
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 08/14/2008 07:34:24
|
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.
|
|
|
 |
|
|