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 CBOT

Date:05/30/05
Author:Jordan Wade
URL:n/a
Comments:0
Info:n/a
Score: (3.25 in 4 votes)
extern void object::BottlesOfBeer()
{

//99 Bottles of Beer on the Wall, by Jordan Wade in CBOT (the Colobot (a 
game from Epsitec) programming language)

int beers; //Number of bottles left

float speed = 1;

/* Speed settings:
0.125 - One message at a time... (54s per bottle, ~ 1.5 hours for song)
 0.25 - Quater speed
  0.5 - Half speed
    0 - DO NOT USE
    1 - Normal
    2 - Double speed
    4 - Quad speed
    8 - Near constant
   16 - Very close to constant
   32 - Constant
*/

//FYI: Any wait instructions can be removed, but since Colobot shows
//     only 4 messages at any one time, you will probably only see the
//     last bottle

for(beers = 99; beers > 0; beers--)
{

//These will display in green boxes

message(beers + " bottles of beer on the wall,", DisplayInfo);
wait(1 / speed);
message(beers + " bottles of beer!", DisplayInfo);
wait(1.75 / speed);
message("Take one down and pass it around,", DisplayInfo);
wait(1.5 / speed);
message((beers - 1) + " bottles of beer on the wall!", DisplayInfo);

wait(2.5 / speed); //Wait time between bottles (in seconds)

}

//And these will display in brown boxes

//Only one beer left!
message("1 bottle of beer on the wall,");
message("1 bottle of beer!");
message("Take one down and pass it around,");
message("No bottles of beer left on the wall!");

}

Download Source | Write Comment

Alternative Versions

Comments

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: