Language haXe
(simple, short, fast and crossplatform)
| Date: | 11/28/09 |
| Author: | tong |
| URL: | http://disktree.net |
| Comments: | 0 |
| Info: | http://haxe.org |
| Score: |
class NinetyNineBottles {
static function sing( i : Int = 99 ) : String {
var num = i, b = new StringBuf();
do {
b.add( i );
if( i == 1 ) {
b.add( " bottle of beer on the wall, " );
b.add( i );
b.add( " bottle of beer.\nTake one down and pass it around, no more bottles" );
} else {
b.add( " bottles of beer on the wall, " );
b.add( i );
b.add( " bottles of beer.\nTake one down and pass it around, " );
b.add( i-1 );
b.add( " bottle" );
b.add( (i==2)?"":"s" );
}
b.add( " of beer on the wall.\n\n" );
} while( --i > 0 );
b.add( "No more bottles of beer on the wall, no more bottles of beer.\n" );
b.add( "Go to the store and buy some more, " );
b.add( num );
b.add( " bottles of beer on the wall." );
return b.toString();
}
static function main() {
#if neko
neko.Lib.print( sing( 99 ) );
#end
}
}
Download Source | Write Comment
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!
Comments