Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
Sentinel Loop Exercise
Old
gskidmark
Guest
 
Status:
Posts: n/a
Default Sentinel Loop Exercise - 05-14-2011, 10:05 AM

I am stuck on exercise 3 at the end of chapter 4. The exercise is this:
Add a tree to the triple jump while loop world. Make the sentinel to be the tree's height, rather than the number 5., so that the loop will execute when the distance is less than or equal to the tree's height, but stop when the distance passes its height. To do this, you can use the character-level function that returns an object's height.

I added a birch tree to the world. I am keeping the counter. I am changing the while instruction to tell it to keep running as long as long as the distance the whiteRabbit is traveling is less than or equal to the height of birchTree.

I kept the counter and tried these while instructions:
While birchTree height is below whiteRabbit height
While birchTree height is >/= whiteRabbit distance above ground
While whiteRabbit distance to ground is < birchTree height

None of these worked. I then realized that I am missing the character-level function that returns an object's height.

I am not sure if any of those while instructions are correct but I won't know until I get it to report the object's height. I must be overlooking something in the book because I do not know how to get it to report this. Can someone point me in the right direction?
   
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.