-
Notifications
You must be signed in to change notification settings - Fork 81
/
Copy pathStructural.Bridge.Pattern.pas
61 lines (46 loc) · 1.01 KB
/
Structural.Bridge.Pattern.pas
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
61
unit Structural.Bridge.Pattern;
interface
uses
SysUtils;
type
IBridge = interface
['{FB1F4FB1-8AD8-48FD-AEA5-1E33B4628879}']
function OperationImp: String;
end;
TAbstraction = class
private
FBridge: IBridge;
public
constructor Create(implement: IBridge);
function Operation: string;
end;
TImplementationA = class(TinterfacedObject, IBridge)
public
function OperationImp: string;
end;
TImplementationB = class(TInterfacedObject, IBridge)
public
function OperationImp: string;
end;
implementation
{ TAbstraction }
constructor TAbstraction.Create(implement: IBridge);
begin
inherited Create();
FBridge := implement;
end;
function TAbstraction.Operation: string;
begin
WriteLn('Abstraction' + ' <<< BRIDGE >>> ' + FBridge.OperationImp);
end;
{ TImplemetationA }
function TImplementationA.OperationImp: string;
begin
Result := 'Implementation A';
end;
{ TImplementationB }
function TImplementationB.OperationImp: string;
begin
Result := 'Implementation B';
end;
end.