![]() |
Assignment 6
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. |
All times are GMT -5. The time now is 04:22 AM. |
Copyright ©2023, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.