Alice Community

Alice Community (http://www.alice.org/community/index.php)
-   Questions and Comments (http://www.alice.org/community/forumdisplay.php?f=9)
-   -   Assignment 6 - Loops (http://www.alice.org/community/showthread.php?t=11254)

shaolinkidd 07-28-2015 01:59 PM

Assignment 6 - Loops
 
I recently completed this one. We had to make a character that sang the 99 bottles of pop song all the way down to 0. We were supposed to use a 'While' statement however I could not get that to work so I didn't use it and accomplished the same goal. If you did yours with the 'While' statement, I would like to know how you did it.:D

MrMoke 07-28-2015 07:14 PM

Depending on the final verse either
While counter > 0
or
While counter >= 0
..sing
..dec the counter

CodeMan 07-28-2015 08:04 PM

[QUOTE=shaolinkidd;56635]I recently completed this one. We had to make a character that sang the 99 bottles of pop song all the way down to 0. We were supposed to use a 'While' statement however I could not get that to work so I didn't use it and accomplished the same goal. If you did yours with the 'While' statement, I would like to know how you did it.:D[/QUOTE]

Just curious how did you do it?

Petit Suisse 07-30-2015 02:42 AM

I'm also curious how you did it without a while statement. You're quite creative.

My solution:
[url]http://gyazo.com/b08e6c0aa7b56d02a0fb3b09210ae065[/url]

shaolinkidd 08-06-2015 11:58 AM

loops
 
[QUOTE=CodeMan;56642]Just curious how did you do it?[/QUOTE]

I used a loop with a counter that incremented by 1 up to (but not including) 100 times

shaolinkidd 08-06-2015 01:47 PM

Assignment 6
 
1 Attachment(s)
[QUOTE=shaolinkidd;56679]I used a loop with a counter that incremented by 1 up to (but not including) 100 times[/QUOTE]

See attached...

shaolinkidd 08-06-2015 01:51 PM

Assignment 6
 
[url]https://gyazo.com/a466644d1a0ce42fb1ecbdfa29e16f03[/url]

chickentree 08-06-2015 03:37 PM

[QUOTE=shaolinkidd;56682][url]https://gyazo.com/a466644d1a0ce42fb1ecbdfa29e16f03[/url][/QUOTE]

ndx = 99
while ndx > 0[INDENT]Do all your singing stuff
ndx=ndx-1[/INDENT]
stuff to do after the song has ended.

When you get to 1 it will sing about one bottle of soda and decrement ndx to 0 at which point the while loop will exit
Note: for testing I would make ndx=3 and make sure everything works then change it to 99 before you submit it.

Mark

noface0711 03-23-2016 08:11 AM

I'm also curious how you did it without a while statement. You're quite creative.

RavenOfCode 03-23-2016 03:54 PM

[QUOTE=shaolinkidd;56681]See attached...[/QUOTE]

I see, not the way I would do it but it works. :)


All times are GMT -5. The time now is 02:55 PM.

Copyright ©2024, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.