Skip to content

Commit c88f149

Browse files
Inclusão da Interface IPrototype
1 parent d5ce6ea commit c88f149

7 files changed

+505
-53
lines changed

Prototype-AndreCelestino/uReuniao.pas Prototype-AndreCelestino/Pattern.ConcretePrototype.pas

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
unit uReuniao;
1+
unit Pattern.ConcretePrototype;
22

33
interface
44

55
uses
6-
SysUtils, Controls, Graphics;
6+
SysUtils, Controls, Graphics, Pattern.Prototype;
77

88
type
9-
TReuniao = class
9+
{ Concrete Prototype }
10+
TConcretePrototype = class(TInterfacedObject, IPrototype)
1011
private
1112
FNome: string;
1213
FData: TDate;
@@ -17,7 +18,7 @@ TReuniao = class
1718
constructor Create;
1819

1920
// método principal do Prototype
20-
function Clonar: TReuniao;
21+
function Clonar: IPrototype;
2122

2223
property Nome: string read FNome write FNome;
2324
property Data: TDate read FData write FData;
@@ -30,12 +31,12 @@ implementation
3031

3132
{ TReuniao }
3233

33-
function TReuniao.Clonar: TReuniao;
34+
function TConcretePrototype.Clonar: IPrototype;
3435
var
35-
NovaReuniao: TReuniao;
36+
NovaReuniao: TConcretePrototype;
3637
begin
3738
// cria um novo objeto
38-
NovaReuniao := TReuniao.Create;
39+
NovaReuniao := TConcretePrototype.Create;
3940

4041
// copia todas as propriedades do objeto atual,
4142
// atribuindo-as ao clone
@@ -49,7 +50,7 @@ function TReuniao.Clonar: TReuniao;
4950
result := NovaReuniao;
5051
end;
5152

52-
constructor TReuniao.Create;
53+
constructor TConcretePrototype.Create;
5354
begin
5455
FData := Date;
5556
FHora := Time;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
unit Pattern.Prototype;
2+
3+
interface
4+
5+
type
6+
{ Prototype }
7+
IPrototype = interface
8+
// método principal do Prototype
9+
function Clonar: IPrototype;
10+
end;
11+
12+
implementation
13+
14+
end.
+6-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
program Prototype;
1+
program Prototype;
22

33
uses
44
Forms,
5-
uTela in 'uTela.pas' {fTela},
6-
uReuniao in 'uReuniao.pas';
5+
View.Formulario in 'View.Formulario.pas' {fFormulario},
6+
Pattern.Prototype in 'Pattern.Prototype.pas',
7+
Pattern.ConcretePrototype in 'Pattern.ConcretePrototype.pas';
78

89
{$R *.res}
910

1011
begin
1112
Application.Initialize;
12-
Application.Title := 'Exemplo de Prototype';
13-
Application.CreateForm(TfTela, fTela);
13+
Application.Title := 'Exemplo de Prototype - André Celestino';
14+
Application.CreateForm(TfFormulario, fFormulario);
1415
Application.Run;
1516
end.

0 commit comments

Comments
 (0)