Alice Community  

Go Back   Alice Community > General Discussion > The Lounge

Reply
 
Thread Tools Display Modes
Lab 2
Old
Kirk MacLean
Junior Member
 
Status: Offline
Posts: 7
Join Date: Aug 2016
Location: Texas
Default Lab 2 - 10-12-2016, 09:25 PM

I had a pretty hard time with this lab. Everything started off great and but I am not even sure I did the assignment how he wanted it to be done. I have a skeleton in a junkyard and he asks you to input a number. He jumps up and spins around that many times and comes back down. He asks you if you want him to do it again and then does it again if yes and says goodbye if no. When I explain what the program does it sounds like I did the assignment how he wants it but not sure if I did it the loop way he wanted it to be. I got stuck a couple times with getting my loops in the right spots. For a while when the answer was no my skeleton would just ask again and again and again. I finally found a way to get him to stop instead of using the loop I used While. I really hope I did the assignment the way the instructor wanted it to be. Anybody else get stuck in a continuous loop when you tried to end it? Things are definitely starting to get harder haha.
   
Reply With Quote
Old
lucyrn99
Member
 
Status: Offline
Posts: 23
Join Date: Aug 2016
Location: Dallas TX
Default 10-14-2016, 12:06 AM

Yes, this one is challenging!
I have my character spinning the correct number of times, but I can't get the part where I ask the user 'do you want the object to spin again? question, and if they say 'yes', make the loop happen.

I'm using a string type variable for my 'yes or no' question.
I'm also using the 'if' statement to say 'if yes or no == yes', then repeat the spin process.

It's not working at all, when I answer 'yes'.

I've also tried the 'while' statement to see if 'while "true", make the object spin again' would work, but it did not..

Back to the drawing board, and more reading.. this is not as simple as I thought it would be!
   
Reply With Quote
Old
chickentree
Super Moderator
 
Status: Offline
Posts: 250
Join Date: Dec 2012
Location: Frosno, Ca
Default 10-14-2016, 12:59 AM

Quote:
Originally Posted by lucyrn99 View Post
Yes, this one is challenging!
I have my character spinning the correct number of times, but I can't get the part where I ask the user 'do you want the object to spin again? question, and if they say 'yes', make the loop happen.

I'm using a string type variable for my 'yes or no' question.
I'm also using the 'if' statement to say 'if yes or no == yes', then repeat the spin process.

It's not working at all, when I answer 'yes'.

I've also tried the 'while' statement to see if 'while "true", make the object spin again' would work, but it did not..

Back to the drawing board, and more reading.. this is not as simple as I thought it would be!
The while block will repeat as long as the statement evaluates to true. Since true will always equal true the while will continue forever.
Depending on how it was written several things could be happening.
You could have declared a variable called yes and another called no. Which would have been set to some value. Your expression is (yes or no == yes) this will first evaluate yes or no. Remember that in this case yes does not mean "yes" instead yes is a label for a variable. The variable can hold a certain type of value like a number, a Boolean (true or false) or a string.
The (yes or no ) will look at the contents of the variables and if Alice considers either variable to be true then the result will be true. At this point Alice will have ((yes or no)==yes -> (true == yes). Finally, if the contents of the variable yes equals true then the final result will be true otherwise it will be false.

Here is what you need to do:

create a string variable called answer
set the value to "yes"

while answer == "yes"
do whatever
Ask if the user wants to continue
// from here the code goes back to the while

// if the answer is anything else then you end up here and continue on

Last note: if the user types anything but "yes" the while will end. This includes Yes YES yeS yes with a space on either end....


Mark Henwood
mhenwood@ieee.org
   
Reply With Quote
Lab 2 - make object jump and spin, use loop statement
Old
lucyrn99
Member
 
Status: Offline
Posts: 23
Join Date: Aug 2016
Location: Dallas TX
Default Lab 2 - make object jump and spin, use loop statement - 10-15-2016, 12:04 PM

Hi all,

This assignment was a struggle for me..
I created a string type variable for the 'yes or no' question.

After the object jumps and spins the first time, I have the user answer the 'yes or no' question, but my program does not work as expected after they answer the question.

I've tried the While statement, as well as the If statement, to say 'while or if 'yes or no' == 'yes', make the object jump and spin.
This hasn't worked.

A helpful Alice community member posted a reply to my issue:
http://www.alice.org/community/showthread.php?t=11601

I tried what he suggested, but still couldn't get it to work.. has anyone figured out how to make this work successfully?
   
Reply With Quote
Merge And Comment
Old
chickentree
Super Moderator
 
Status: Offline
Posts: 250
Join Date: Dec 2012
Location: Frosno, Ca
Default Merge And Comment - 10-15-2016, 01:10 PM

Quote:
Originally Posted by lucyrn99 View Post
Hi all,

This assignment was a struggle for me..
I created a string type variable for the 'yes or no' question.

After the object jumps and spins the first time, I have the user answer the 'yes or no' question, but my program does not work as expected after they answer the question.

I've tried the While statement, as well as the If statement, to say 'while or if 'yes or no' == 'yes', make the object jump and spin.
This hasn't worked.

A helpful Alice community member posted a reply to my issue:
http://www.alice.org/community/showthread.php?t=11601

I tried what he suggested, but still couldn't get it to work.. has anyone figured out how to make this work successfully?
Hi lucyrn99

First I merged this with the original thread as this is not really a new issue and all the information should be kept together.

That said, if you would kindly post a copy of your movie to date I would be glad to help you. It is impossible to go further without seeing what you have so far. In general there are multiple right ways to accomplish something in a program and an infinite number of wrong ways. Without knowing where you are at I can not help you much more.

Mark


Mark Henwood
mhenwood@ieee.org
   
Reply With Quote
Reply

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