Voting

Category

real language

Bookmarking

Del.icio.us Digg Diigo DZone Earthlink Google Kick.ie
Windows Live LookLater Ma.gnolia Reddit Rojo StumbleUpon Technorati

Language ActionScript

(standard version)

Date:04/20/05
Author:David Fichtmueller
URL:n/a
Comments:3
Info:n/a
Score: (1.64 in 11 votes)
//  "99 bottles of beer" in ActionScript
//  by David Fichtmueller ( david@fichtmueller.de )

b = 99;
for (i=1; i<=99; i++) {
	txt = txt+b+" bottle(s) of beer on the wall. "+b+" bottle(s) of beer. Take 
one down, pass it around, ";
	b = b-1;
	txt = txt+b+" bottle(s) of beer on the wall. ";
}
stop ();

Download Source | Write Comment

Alternative Versions

VersionAuthorDateCommentsRate
update (tippfehler!!!)atom300001/10/065
object-oriented versionUnknown04/20/050

Comments

>>  Jeroen Beckers said on 06/11/05 18:34:17

Jeroen Beckers This is way better:

var total = new String();
for (i=99; i>0; i--) {
total += (i+" bottle(s) of beer on the wall. "+i+" bottle(s) of beer. Take one down, pass it around, ";);
total += (i-1)+" bottle(s) of beer on the wall. ";
}
trace(total);
stop ();

>>  Guido Jansen said on 02/27/06 09:21:07

Guido Jansen Mine is correct

// "99 bottles of beer" in ActionScript
// by Guido Jansen (guido_jansen@gmx.de)

plu = "bottles"
sin = "bottle"
for (i = 99; i >= 0; i--) {
out += (i != 0 ? i : "No more";) + " " + (i == 1 ? sin : plu) + " of beer on the wall. ";
out += (i != 0 ? i : "No more";) + " " + (i == 1 ? sin : plu) + " of beer.\n";
if(i != 0)
{
out += "Take one down, pass it around, ";
out += (i-1 != 0 ? i-1 : "no more";) + " " + (i-1 == 1 ? sin : plu) + " of beer on the wall.\n";
} else
{
out += "Go to the store and buy some more, 99 bottles of beer on the wall."
}
out += "\n"
}
trace(out)
stop ();

>>  Goura said on 05/04/09 22:09:20

Goura for > while

Download Source | Write Comment

Add Comment

Please provide a value for the fields Name, Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.

Please don't post large portions of code here! Use the form to submit new examples or updates instead!

Name:

eMail:

URL:

Security Code:
  
Comment: