Alice Community  

Go Back   Alice Community > General Discussion > The Lounge

Thread Tools Display Modes
Loops and While statements
Posts: n/a
Default Loops and While statements - 03-08-2009, 06:30 PM

This assignment started out tricky. I had to make an object ( I used the male ballet dancer ) jump up and turn a X amount of times depending on the users input answer. Then when he landed i had to have the user input yes or no if they wanted to run it again. This was easily done by using the ask user for yes or no. But the bonus points.

For bonus points we had to have the world run over and over if the user entered YES, Yes, or yes. I tried using a mixture of if/else and while statements only to have it freeze. So i finally found my solution.

I started by using an If/Else statement. For if i used, if answer == Yes OR answer == yes OR answer == YES. The OR was the key to my success. Inside the if statement i had. If it was true (all 3 YES,Yes,yes) it ran a while statement which had my jumping functions in it. At the end it asked the user the question Do you want to run this again? No matter what Yes you used for your answer it would run everything again. If you typed in anything other then one of the 3 yes it would stop running.
Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Copyright ©2019, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.