PDA

View Full Version : Getting Loopy - Lab2


Mauricio
10-16-2016, 12: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.

MrMoke
10-16-2016, 07: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.

chickentree
10-17-2016, 05: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