1. Home
  2. Computing & Technology
  3. Delphi Programming

The Adapter Pattern - Delphi OOP Part 10 - Chapter 22

By Zarko Gajic, About.com Guide

Complex Adapter Pattern Chp 22

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...

Explore Delphi Programming
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming
  4. Coding Delphi Applications
  5. OOP in Delphi
  6. Free Online OOP Course
  7. The Adapter Pattern - Delphi OOP Part 10 - Chapter 22

©2009 About.com, a part of The New York Times Company.

All rights reserved.