[THE_99_BOTTLES_SONG Application Class]
[Wall class]
import THE_99_BOTTLES_SONG:*;
class Wall
method Wall();
method Sing();
method TakeOneDown() Returns Bottle;
property array of Bottle theBottles;
end-class;
method Wall
&theBottles = CreateArrayRept(create Bottle(), 99);
%This.Sing();
end-method;
method Sing
Local number &howMany;
Local Bottle &theBottle;
%Response.Write("
99 Bottles of Beer Song
");
&howMany = &theBottles.Len;
While &howMany > 0
%Response.Write(&howMany | " bottles of beer on the wall, " |
&howMany | " bottles of beer,");
&theBottle = %This.TakeOneDown();
&theBottle.PassAround();
&howMany = &theBottles.Len;
If &howMany = 0 Then
%Response.Write("No more bottles of beer on the wall.");
Else
%Response.Write(&howMany | " bottles of beer.");
End-If;
End-While;
end-method;
method TakeOneDown
/+ Returns THE_99_BOTTLES_SONG:Bottle +/
Local Bottle &theBottle;
%Response.Write("Take one down ");
&theBottle = &theBottles.Pop();
Return &theBottle;
end-method;
[Bottle class]
class Bottle
method Bottle();
method PassAround();
end-class;
method Bottle
end-method;
method PassAround
%Response.Write("and pass it around,");
end-method;
[script to invoke the song]
import THE_99_BOTTLES_SONG:*;
Function ISCRIPT_99_bottles
Local Wall &myWall;
&myWall = create Wall();
End-Function;