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.43 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.1.0.42 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.1.0.41 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.1.0.40 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.1.0.39 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.1.0.38 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.1.0.37 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.1.0.36 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.1.0.34 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.1.0.33 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.1.0.32 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.1.0.31 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.1.0.30 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.1.0.29 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.1.0.28 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.1.0.27 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.1.0.26 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.1.0.25 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.1.0.24 tracks/delphi/exercises/beer-song/uBeerSongExample.pas
trackler-2.1.0.23 tracks/delphi/exercises/beer-song/uBeerSongExample.pas