Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: loops in GUI
04-03-2014, 06:22 PM #1
- Join Date
- Dec 2013
- Thanked 0 Times in 0 Posts
loops in GUI
I've made loops before, but never in GUI, i don't know if it's the same, or very different. I have no idea were to start, I'm making a loop for my Tic-Tac-Toe code. I was wondering if anyone could explain how to make a loop in my tic-tac-toe code.
04-03-2014, 07:04 PM #2
- Join Date
- Sep 2002
- Saskatoon, Saskatchewan
- Thanked 2,662 Times in 2,631 Posts
There is no difference between a loop in a gui and a loop in a command line program. The only difference is that a command line program typically needs a termination loop to run while the user wants to keep it running, while a framed program does not since it can detect the closure events, so you may save one by using a gui.
You don't need a loop in this code, you simply need to use another if branch so when a winner is determined you ask if they want to continue and clear the board if they do. I'd write a method for it to keep it simple. I'm not going to go through the code for the evaluation, but its near the bottom where it shows the win. So long as all buttons have been assigned, than you can prompt for a replay. A replay simply resets everything, so you'll want to modify the members to not initialize the variables, and use a method that does that for you. Call that method whenever a game is to be reset.PHP Code:
header('HTTP/1.1 420 Enhance Your Calm');