Language Vala
| Date: | 04/16/07 |
| Author: | Kahnamta |
| URL: | n/a |
| Comments: | 2 |
| Info: | http://live.gnome.org/Vala |
| Score: |
/* 99 Bottles of Beer in Vala (live.gnome.org/Vala)
by Kahnamta, Apr 15 2007 */
using GLib;
public class Beer {
private int bottles = 99;
public void drink() {
if (bottles > 2) {
stdout.printf("%d bottles of beer on the wall.\n", bottles);
stdout.printf("%d bottles of beer.\n", bottles);
stdout.printf("Take one down, pass it around\n");
stdout.printf("%d bottles appear on the wall!\n\n", --bottles);
drink();
}
else if (bottles == 2) {
stdout.printf("Two bottles of beer on the wall.\n");
stdout.printf("Two bottles of beer.\n");
stdout.printf("Take one down, pass it around\n");
stdout.printf("One bottle appear on the wall!\n\n");
bottles--;
drink();
}
else {
stdout.printf("One bottle of beer on the wall.\n");
stdout.printf("One bottle of beer.\n");
stdout.printf("Take it down, pass it around\n");
stdout.printf("No more bottles appear on the wall!\n\n");
}
}
static int main(string[] args) {
var bottle = new Beer();
bottle.drink();
return 0;
}
}
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