Program is stuck after choosing a door how do I fix?

From ggc

Jump to: navigation, search

My code can be found at http://ggc.javawide.org/index.php/ChrisHull/Montyhall

I made it so the prizes behind the doors are randomized and when you click on a door it will always reveal a different door with a loser prize on it but never a winner prize. How do I made it so it prompts to stay or switch and also how do I get it not stop after clicking on one door? What does each stage do? Where do I put the stages?

From line 127 to 178 describes well what it should do at the beginning of the game. Once the user has clicked on the first door, you never need to execute these statements again. One way you can make them execute at the beginning, but not after they select the door is to include them in an if statement:

if(stage==0)
{
    //put your lines 127-178 here
}
else if(stage==1)
{
    //write more code here for what to do next
}

In addition, you need to change the value of stage once the player picks the first door. For example, on line 129, you should put

stage=1;

This way after the player clicks on door 1, the code in lines 127-178 will never execute again (since stage is now 1.

When you write the //write more code here for what to do next you can make it respond to staying or switching. An easy way to do this is have them click on the door they want to open and repeat code similar to your code in lines 127-178.





Views
Personal tools
Add to 
del.icio.usAdd to 
diggAdd to 
FacebookAdd to 
favoritesAdd to 
GoogleAdd to 
MySpaceAdd to 
PrintAdd to 
SlashdotAdd to 
StumbleUponAdd to 
Twitter