99 bottles of beer: Difference between revisions
Content added Content deleted
Not a robot (talk | contribs) (Add Miranda) |
No edit summary |
||
Line 4,083: | Line 4,083: | ||
(message "%d bottles of beer on the wall" (1- i)) |
(message "%d bottles of beer on the wall" (1- i)) |
||
(setq i (1- i))))</syntaxhighlight> |
(setq i (1- i))))</syntaxhighlight> |
||
=={{header|EMal}}== |
|||
<syntaxhighlight lang="emal"> |
|||
type NinetynineBottles |
|||
int DEFAULT_BOTTLES_COUNT = 99 |
|||
text BASE_SUBJECT = "bottle" |
|||
model |
|||
int initialBottlesCount, bottlesCount |
|||
new by int bottlesCount |
|||
me.initialBottlesCount = bottlesCount |
|||
me.bottlesCount = bottlesCount |
|||
end |
|||
fun subject = text by block do return when(me.bottlesCount == 1, BASE_SUBJECT, BASE_SUBJECT + "s") end |
|||
fun bottles = text by block do return when(me.bottlesCount == 0, "No more", text!me.bottlesCount) end |
|||
fun goToWall = void by block |
|||
text line = me.bottles() + " " + me.subject() + " of beer on the wall, " + |
|||
me.bottles() + " " + me.subject() + " of beer." |
|||
writeLine(line) |
|||
end |
|||
fun takeOne = logic by block |
|||
if --me.bottlesCount < 0 do return false end # cannot take a beer down |
|||
writeLine("Take one down and pass it around, " + me.bottles() + |
|||
" " + me.subject() + " of beer on the wall.") |
|||
writeLine() |
|||
return true |
|||
end |
|||
fun goToStore = void by block |
|||
writeLine("Go to the store and buy some more, " + me.initialBottlesCount + |
|||
" bottles of beer on the wall.") |
|||
end |
|||
fun play = void by block |
|||
for ever |
|||
me.goToWall() |
|||
if not me.takeOne() |
|||
me.goToStore() |
|||
break |
|||
end |
|||
end |
|||
end |
|||
end |
|||
NinetynineBottles(when(Runtime.args.length > 0, int!Runtime.args[0], DEFAULT_BOTTLES_COUNT)).play() |
|||
</syntaxhighlight> |
|||
=={{header|Erlang}}== |
=={{header|Erlang}}== |