mementounit1.pas

来自「设计模式delphi版给想学delphi的朋友一个很有价值的参考」· PAS 代码 · 共 60 行

PAS
60
字号
unit MementoUnit1;

interface
type
  TState = class
  end;

  TMemento = class
  private
    f_state: TState;
    constructor Create;
    procedure SetState(s: TState);
    function GetState(): TState;
  public
    destructor Destroy; virtual;
  end;

  TOrigintor = class
  private
    f_state: TState;
  public
    function CreateMemento(): tmemento;
    procedure SetMemento(amemento: TMemento);
  end;

implementation

function TOrigintor.CreateMemento(): tmemento;
begin
//.....
end;

procedure TOrigintor.SetMemento(amemento: TMemento);
begin
//.....
end;

constructor TMemento.Create;
begin
//.....
end;

procedure TMemento.SetState(s: TState);
begin
//.....
end;

function TMemento.GetState(): TState;
begin
//.....
end;

destructor TMemento.Destroy;
begin
//.....
end;

end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?