| | |
Tic Tac Toe help
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
Do your own homework. You have a month, do it. God, asking for someone to do your work for you, then saying, in the same breath no less, that you want to master the language. Well, buddy, those two statements just do not go together.
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
If somebody writes the game for you, it is going to work adversly towards your mastering of the language. Google would be a good place to start, and not just the first results page.
since you are taking the subject, you'll propably have examples in your textbook or a course. try to understand what they do, create alternative sollutions, ...
this is a better (and faster) way to learn java than asking someone you don't know and who'll propably use code you don't understand to make it for you.
just choose for yourself what kind of program you want, decide on the classes, make them and use them. even if the program isn't completed at the end of the month, at least your teacher will see you've given it some effort.
this is a better (and faster) way to learn java than asking someone you don't know and who'll propably use code you don't understand to make it for you.
just choose for yourself what kind of program you want, decide on the classes, make them and use them. even if the program isn't completed at the end of the month, at least your teacher will see you've given it some effort.
I wrote a tic-tac-toe program in about an hour for AP Computer Science. In a week we wrote a fully functional monopoly. (just to give you an idea of what a month can do)
Suggestion for implementation of a tic-tac-toe program:
Make a grid of buttons with transparent .gifs via loop(using gridbag or something to make the 3x3 grid) and place them into a two dimensional array (or populate a two dimensional array with a small class representing the buttons). The buttonclick method could then replace the button being clicked with either an x or an o .gif, then call a method to check for 3 of the same .gifs (or flag variables in the classes) in a row in the various directions. Once one of the players wins, display a win message and disable the buttons.
The one that I wrote was 3 classes and totaled only 340 lines including the gui. A tic-tac-toe program shouldn't take you very long at all to write, so knock it out early and enjoy your month :p
Suggestion for implementation of a tic-tac-toe program:
Make a grid of buttons with transparent .gifs via loop(using gridbag or something to make the 3x3 grid) and place them into a two dimensional array (or populate a two dimensional array with a small class representing the buttons). The buttonclick method could then replace the button being clicked with either an x or an o .gif, then call a method to check for 3 of the same .gifs (or flag variables in the classes) in a row in the various directions. Once one of the players wins, display a win message and disable the buttons.
The one that I wrote was 3 classes and totaled only 340 lines including the gui. A tic-tac-toe program shouldn't take you very long at all to write, so knock it out early and enjoy your month :p
Last edited by TheGathering; Jul 9th, 2007 at 10:59 am.
Whoops, missed the part with "except" on the tic tac toe idea. :p
Connect 4 is an easy game that can be done with an expanded version of the "Suggestion for implementation of a tic-tac-toe program:" above with the addition of a timer and using only a single row of actual buttons.
Monopoly is an easy game to write if you keep it basic, though requires lots of gui code, which can take time to work through if you get something wrong.
If you don't like guis and prefer algorithms, you can try Tetris (friend of mine wrote one in about a week and a half) or simple card games as stated above.
Connect 4 is an easy game that can be done with an expanded version of the "Suggestion for implementation of a tic-tac-toe program:" above with the addition of a timer and using only a single row of actual buttons.
Monopoly is an easy game to write if you keep it basic, though requires lots of gui code, which can take time to work through if you get something wrong.
If you don't like guis and prefer algorithms, you can try Tetris (friend of mine wrote one in about a week and a half) or simple card games as stated above.
•
•
•
•
I think he already left once he found out we wouldn't just hand him a completed assignment to turn in.
He still has 26 days before he realizes no-one else will give him a completed assignment either. :p
I think the connect 4 idea was good anyways. I hope he comes back and tries it.
![]() |
Similar Threads
- Tic-Tac-Toe (C++)
- Tic Tac Toe Homework (C++)
- Tic Tac toe help (C)
- Tic Tac Toe AI help, where to reset variables. (C++)
Other Threads in the Java Forum
- Previous Thread: How to implement a binary tree Using HashMap Collection in java
- Next Thread: classes for an online share trading system
| Thread Tools | Search this Thread |
911 actionlistener addressbook android api append applet application array arrays automation binary bluetooth character chat class classes client code component consumer csv database desktop developmenthelp eclipse error exception fractal ftp game givemetehcodez graphics gui html ide image input integer j2me japplet java javaarraylist javac javaee javaprojects jmf jni jpanel julia linked linux list loop mac map method methods mobile netbeans newbie objects online oriented panel print printf problem program programming project projects properties recursion replaydirector reporting researchinmotion robot rotatetext rsa scanner screen se server set size sms sort sql string swing template test threads time tree ubuntu update windows working





