View Single Post
Getting Loopy - Lab2
Old
Mauricio
Member
 
Status: Offline
Posts: 14
Join Date: Aug 2016
Default Getting Loopy - Lab2 - 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.
   
Reply With Quote