Skip to content

Instantly share code, notes, and snippets.

@bero
Last active December 29, 2021 08:44
Show Gist options
  • Save bero/f55f055c7efa83ac3d5eb98f98ed91a9 to your computer and use it in GitHub Desktop.
Save bero/f55f055c7efa83ac3d5eb98f98ed91a9 to your computer and use it in GitHub Desktop.
Raindrops.pas
unit uRaindrops;
interface
type
TRainDrop = class
public
function Convert(Value: Integer): string;
end;
function RainDrops: TRainDrop;
implementation
uses
SysUtils;
function RainDrops: TRainDrop;
begin
// No need to call TRainDrop.Create ???
end;
{ TRainDrop }
function TRainDrop.Convert(Value: Integer): string;
begin
Result := '';
if Value mod 3 = 0 then
Result := Result + 'Pling';
if Value mod 5 = 0 then
Result := Result + 'Plang';
if Value mod 7 = 0 then
Result := Result + 'Plong';
if Result = '' then
Result := Value.ToString;
end;
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment