-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvisitor.model.item.pas
86 lines (69 loc) · 1.67 KB
/
visitor.model.item.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
unit visitor.model.item;
{$mode ObjFPC}{$H+}
interface
uses
Classes, SysUtils, Visitor.Model.Interfaces,
visitor.model.item.regra.varejos, visitor.model.item.regra.atacado;
type
{ TModelItem }
TModelItem = class(TInterfacedObject, iItem, iItemRegras, iVisitable)
private
FPrecoUnitario: currency;
FVisitor: iVisitor;
public
constructor Create;
destructor Destroy; override;
class function New: iItem;
function SetPrecoUnitario(Value: currency): iItem;
function PrecoUnitario: currency;
function PrecoVenda: currency;
function PrecoPromocao: currency;
function Accept(Value: iVisitor): iItemRegras;
function Visitor: iVisitor;
function Regras: iVisitable;
end;
implementation
{ TModelItem }
constructor TModelItem.Create;
begin
FVisitor := TModelItemRegraVarejo.New.Visitor;
end;
destructor TModelItem.Destroy;
begin
inherited Destroy;
end;
class function TModelItem.New: iItem;
begin
Result := Self.Create;
end;
function TModelItem.SetPrecoUnitario(Value: currency): iItem;
begin
Result := Self;
FPrecoUnitario := Value;
end;
function TModelItem.PrecoUnitario: currency;
begin
Result := FPrecoUnitario;
end;
function TModelItem.PrecoVenda: currency;
begin
Result := FVisitor.Visit(Self).PrecoVenda;
end;
function TModelItem.PrecoPromocao: currency;
begin
Result := FVisitor.Visit(Self).PrecoPromocao;
end;
function TModelItem.Accept(Value: iVisitor): iItemRegras;
begin
FVisitor := Value;
Result := FVisitor.Visit(Self);
end;
function TModelItem.Visitor: iVisitor;
begin
Result := FVisitor;
end;
function TModelItem.Regras: iVisitable;
begin
Result := Self;
end;
end.