-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathStructural.Decorator.Example.pas
More file actions
41 lines (31 loc) · 949 Bytes
/
Structural.Decorator.Example.pas
File metadata and controls
41 lines (31 loc) · 949 Bytes
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
unit Structural.Decorator.Example;
interface
uses
Structural.Decorator.Pattern;
procedure Example;
implementation
procedure Example;
var
decB: TDecoratorB;
component, decoratorA, decoratorB: IComponent;
begin
WriteLn('Decorator Pattern' + #10);
try
component := TComponent.Create;
decoratorA := TDecoratorA.Create(component);
decoratorB := TDecoratorB.Create(component);
TClient.Display('1. Basic component : ', component);
TClient.Display('2. A-Decorated : ', decoratorA);
TClient.Display('3. B-Decorated : ', decoratorB);
decoratorB := TDecoratorB.Create(decoratorA);
TClient.Display('4. B-A-Decorated : ', decoratorB);
decB := TDecoratorB.Create(component);
decoratorA := TDecoratorA.Create(decB);
TClient.Display('5. A-B-Decorated : ', decoratorA);
WriteLn(decB.addedState + decB.AddedBehaviour);
finally
// Don't free it!
// decB.Free;
end;
end;
end.