Last active
December 29, 2021 08:44
-
-
Save bero/f55f055c7efa83ac3d5eb98f98ed91a9 to your computer and use it in GitHub Desktop.
Raindrops.pas
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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