Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: loops in GUI

  1. #1
    New Coder
    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.
    Attached Files Attached Files

  2. #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Saskatoon, Saskatchewan
    Thanked 2,668 Times in 2,637 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'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts