Computer Science Canada

Rock paper scissors! Exiting

Author:  Tasuba [ Sat Apr 03, 2010 8:36 pm ]
Post subject:  Rock paper scissors! Exiting

What is it you are trying to achieve?
My program is to play rock paper scissors


What is the problem you are having?
The exit loop would not work


Describe what you have tried to solve this problem
Made more than 1 loop and if statements


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Files are attached


Please specify what version of Turing you are using
Turing 4.1.1

Author:  ProgrammingFun [ Sat Apr 03, 2010 9:22 pm ]
Post subject:  RE:Rock paper scissors! Exiting

You do not have re-post this topic to answer the template, you could have simply posted your problem in the previous thread.

Author:  Zren [ Sat Apr 03, 2010 9:29 pm ]
Post subject:  RE:Rock paper scissors! Exiting

Use a variable and make both loops have an exit when.

Turing:
var exitLoops : boolean := false
loop
    loop
        exit when exitLoops = true
        exitLoops := true
    end loop
    exit when exitLoops = true
end loop

Author:  Tasuba [ Sat Apr 03, 2010 9:44 pm ]
Post subject:  Re: Rock paper scissors! Exiting

well this would work but I also need it to ask if it wants to try again....which was the problem in the start.....sorry for not clarifying

Author:  Zren [ Sat Apr 03, 2010 10:05 pm ]
Post subject:  RE:Rock paper scissors! Exiting

Think how you want the loops structured. Imagine removing all you loops and placing them again. Here's how your game probably wants to work:

Load HS
Play Round of RPS
Check Win/Lose
...
Play Round of RPS
Check Win/Lose
You lost, save HS, play again?
Yes I do
Play Round of RPS
Check Win/Lose
...
Play Round of RPS
Check Win/Lose
You lost, save HS, play again?
No I don't

Author:  Tasuba [ Sun Apr 04, 2010 10:30 am ]
Post subject:  Re: Rock paper scissors! Exiting

problem has been solved.


: