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 Unicon

Date:04/19/06
Author:Christian Meurin
URL:n/a
Comments:1
Info:http://unicon.sourceforge.net/
Score: (3.13 in 110 votes)
# Unicon is a "unified extended dialect" of the Icon programming language. 
# It introduces modern features such as object orientation and such.
# Unicon is the successor of Idol, an earlier attempt at Icon OOP.
# The current source code has been left alone for nearly 2 years, so
# I'm not sure if this is still in development.
#
# http://unicon.sourceforge.net/

package bottlesofbeer

$define BEERMAX 99
$define LOWBEER 1
$define NOBEER 0

class BeerSong()
   method start_chugging()
      local beercount

      beercount := BEERMAX;

      while beercount >= NOBEER do {
        # this could be slightly mistyped, but I'm not sure
        if beercount not LOWBEER then {
           write (beercount, " bottles of beer on the wall,\n");
           write (beercount, " bottles of beer.\n");
        } else {
           write ("One more bottle of beer on the wall,\n");
           write ("One more bottle of beer.\n");
        }

        write ("Take one down, pass it around,\n");

        case beercount of {
           0       : write ("No more bottles of beer on the wall.\n")
           1       : write ("One more bottle of beer on the wall.\n")
           default : write (beercount, " more bottles of beer on the wall.\n")
        }
      }

      write ("Get out of my bar yeh drunk low life!\n");
   end
end

Download Source | Write Comment

Alternative Versions

Comments

>>  Christian Meurin said on 04/22/06 21:20:56

Christian Meurin Slight fix:

while beercount >= LOWBEER do {

I entered the NOBEER constant, oops!

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: