99 bottles of beer: Difference between revisions

Content added Content deleted
(Added version w/ top-level declaration, string interpolation and Object Pascal syntax vs C# syntax)
Line 9,568: Line 9,568:
end;
end;


end.
</syntaxhighlight>


This version uses top-level declarations, string interpolation along with more idiomatic Object Pascal syntax vs C#.Net syntax:

<syntaxhighlight lang="pascal">
namespace _99_beers;

method bottles(number: Integer): String;
begin
if (number = 1) then
Result := "bottle"
else
Result := "bottles";
end;

begin
for n: Integer := 99 downto 1 do
begin
writeLn($"{n} {bottles(n)} of beer on the wall,");
writeLn($"{n} {bottles(n)} of beer,");
writeLn($"Take one down, and pass it around,");
writeLn($"{n-1} {bottles(n-1)} of beer on the wall.");
writeLn();
end;
readLn;
end.
end.
</syntaxhighlight>
</syntaxhighlight>