To test the Assign method, add two buttons, called btnCopy and btnShowCopy, to the existing user interface, declare an additional reference ItemsCopy to a TNewCounter and add the buttons OnClick event handlers and the instantiation for ItemsCopy:
procedure TfrmItems.btnCopyClick(Sender: TObject) ;
begin
ItemsCopy.Assign(Items) ;
btnShowCopy.Click;
end;
procedure TfrmItems.btnShowCopyClick(Sender: TObject) ;
begin
lblTotalItems.Caption := 'Copy value is ' + IntToStr (ItemsCopy.GetValue) ;
end;
initialization
Items := TNewCounter.Create;
ItemsCopy := TNewCounter.Create;
That's it for this chapter, next time we'll discuss about the Adapter pattern for polymorphism...


