Alice Community  

Go Back   Alice Community > General Discussion > The Lounge

Thread Tools Display Modes
Getting Loopy - Lab2
Status: Offline
Posts: 14
Join Date: Aug 2016
Default Getting Loopy - Lab2 - 10-16-2016, 01:14 PM

This by far has been the most difficult and frustrating assignment, but also very satisfying one. For this assignment I created a mummy that asks for the user to enter a number then the mummy jumps up in a pose and spins the number of times entered. I am not sure if I did this assignment correctly for there is a while loop in the code, but not for the spin, only for the running the program as long as the user enters “yes,” “Yes,” or “YES.” In order for the mummy to spin I created a variable called count, and a variable call spinAgain, I dropped the count variable into the mummy’s turn method and then I created a statement using the spinAgain variable along with the “ask user for a number” world function. This allowed for the user to enter any number and have the mummy spin the amount of times specified. Where it got trickier is when I tried to create the loop for the program to run again, I started with an If/Else control statement then dropped a while control statement in the first do nothing space, but it was not working like it was supposed to. So after some hair pulling moments and threating my laptop of ending in a landfill, I deleted the If/Else control statements and kept the while control statement. This seem to do the trick but it would loop only once, after some more trial and error I figure that I need to add another statement asking the user if they would like to run it again and this allowed the loop to work. Finally, for the bonus, I used the world function “either a or b or both” but that only allowed for two options, so more trial and error, then I finally realized that I could create a new function, and so I created a function called “either a, b, c,” then I dropped into to the true part of the while loop and also added the spinAgain variable and made it == to the three “yes” options and finally everything worked like it suppose to.
Reply With Quote
Senior Member
MrMoke's Avatar
Status: Offline
Posts: 501
Join Date: Sep 2007
Location: Austin, Texas
Default 10-16-2016, 08:42 PM

Good Job-
It sounds like you are progressing with a positive and experimental attitude. Successful complicated programs are seldom finished without much trial and error.
The further you get into the functionality of each feature and command, the more options become available.
Reply With Quote
General Recipe for Solving Programming Problems:
Super Moderator
Status: Offline
Posts: 250
Join Date: Dec 2012
Location: Frosno, Ca
Default General Recipe for Solving Programming Problems: - 10-17-2016, 06:52 PM

If you have been staring at the screen for more than about 5 minutes:

Method One:
Do Something!! What you do may not be the "right" thing in terms of solving the problem, it typically wont, but it will start you moving and thinking. I have frequently heard people say to themselves "Well that was dumb, but maybe if I ..."
Although the method seems to work for most people, I can not personally attest to its rate of success since I have never had the problem
Method Two:
Beat your head against something hard until it stops hurting. At this point either the answer will come or you will achieve true enlightenment.

Mark Henwood
Reply With Quote

loop, variables, while loop

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 ©2024, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.