Alice Community  

Go Back   Alice Community > General Discussion > The Lounge

Thread Tools Display Modes
Assignment 6
Junior Member
Status: Offline
Posts: 12
Join Date: Jul 2018
Default Assignment 6 - 07-25-2018, 09:01 AM

I found it to be pretty doable. I just used one statement both ways I did it. I defined a variable called numerOfBottles set initially to 99. I plugged it into my character's say methods by using the a and b function in the world object and had it set the value of numberOfBottles to itself -1 each time the method loops. I find that is you use a loop statement and set the number of loops to the numberOfBottles parameter it will still stop when it hits 0. But the while statement is probably better in these situations. So after trying it that way I used the while statement and set the true box to "while numberOfBottles != 0" and it works just right as rain. I had my character say the song was finished after so I would know the loop had terminated itself.

EDIT: I suppose if you're counting down to zero using a loop statement would work, but if you're counting up you would need to use the while statement or it would never stop, go out of control, and maybe crash the program. I had to think about why I would use one over the other.

Last edited by Forumuser; 07-25-2018 at 09:05 AM. Reason: additional thoughts
Reply With Quote

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.