-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathhello.stringfactory.pas
More file actions
60 lines (49 loc) · 1.44 KB
/
hello.stringfactory.pas
File metadata and controls
60 lines (49 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
unit Hello.StringFactory;
{$mode ObjFPC}{$H+}
interface
uses
Hello.HelloWorldString;
type
/// <summary>
/// Factory class for creating instances of <c>THelloWorldString</c>.
/// Implements the singleton pattern.
/// </summary>
TStringFactory = class
private
class var FInstance: TStringFactory;
/// <summary>
/// Class constructor that initializes the singleton instance.
/// </summary>
class constructor Create;
public
/// <summary>
/// Returns the singleton instance of <c>TStringFactory</c>.
/// </summary>
/// <returns>
/// The singleton instance of <c>TStringFactory</c>.
/// </returns>
class function GetInstance: TStringFactory;
/// <summary>
/// Creates a new <c>THelloWorldString</c> with the given string value.
/// </summary>
/// <param name="Str">The string value to set in the <c>THelloWorldString</c>.</param>
/// <returns>
/// A newly created <c>THelloWorldString</c> instance with the specified value.
/// </returns>
function CreateHelloWorldString(const Str: string): THelloWorldString;
end;
implementation
class constructor TStringFactory.Create;
begin
FInstance := TStringFactory.Create;
end;
class function TStringFactory.GetInstance: TStringFactory;
begin
Result := FInstance;
end;
function TStringFactory.CreateHelloWorldString(const Str: string): THelloWorldString;
begin
Result := THelloWorldString.Create;
Result.Value := Str;
end;
end.