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.2.1.60 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.2.1.59 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.2.1.58 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.2.1.57 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.2.1.56 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.2.1.55 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.2.1.54 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.2.1.53 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.2.1.52 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.2.1.51 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.2.1.50 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.2.1.49 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.2.1.48 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.2.1.47 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.2.1.46 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.2.1.45 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.2.1.44 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.2.1.43 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.2.1.42 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.2.1.41 tracks/delphi/exercises/beer-song/uBeerSongExample.pas