Sha256: 5d6524f66d19652bfb924f3320556e5c5e6332004bae0893fe30dacde356d610

Contents?: true

Size: 1.21 KB

Versions: 189

Compression:

Stored size: 1.21 KB

Contents

unit uBeerSong;

interface

type
  Beer = class
  public
    class function Verse(number: integer): string; static;
    class function Verses(start, stop: integer): string; static;
  end;

implementation
uses System.SysUtils;

class function Beer.Verse(number: integer): string;
begin
  case number of
    0:
    result := 'No more bottles of beer on the wall, no more bottles of beer.\nGo to the store and buy some more, 99 bottles of beer on the wall.\n';

    1:
    result := '1 bottle of beer on the wall, 1 bottle of beer.\nTake it down and pass it around, no more bottles of beer on the wall.\n';

    2:
    result := '2 bottles of beer on the wall, 2 bottles of beer.\nTake one down and pass it around, 1 bottle of beer on the wall.\n';

    else
      result := format(
                 '%d bottles of beer on the wall, %d bottles of beer.\nTake one down and pass it around, %d bottles of beer on the wall.\n',
                 [number, number, number - 1]);
  end; //case
end;

class function Beer.Verses(start, stop: integer): string;
var i: integer;
begin
   result := '';
   for i := start downto stop do
     if i = stop then
       result := result + Verse(i)
     else
       result := result + Verse(i) + '\n';
end;

end.

Version data entries

189 entries across 189 versions & 1 rubygems

Version Path
trackler-2.1.0.22 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.1.0.21 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.1.0.20 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.1.0.19 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.1.0.18 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.1.0.17 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.1.0.16 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.1.0.15 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.1.0.14 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.1.0.13 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.1.0.12 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.1.0.11 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.1.0.10 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.1.0.9 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.1.0.8 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.1.0.7 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.1.0.6 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.1.0.5 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.1.0.4 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.1.0.3 tracks/delphi/exercises/beer-song/uBeerSongExample.pas