unit fmMain;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, ExtCtrls;

type
  TForm1 = class(TForm)
    LabeledEdit1: TLabeledEdit;
    LabeledEdit2: TLabeledEdit;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    LabeledEdit3: TLabeledEdit;
    LabeledEdit4: TLabeledEdit;
    LabeledEdit5: TLabeledEdit;
    BitBtn3: TBitBtn;
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn3Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

uses uController, uAggregatedObj, uContainedObject;

procedure TForm1.BitBtn1Click(Sender: TObject);
var
  aController : IController;
  aAggObj : IAggInterface;
  sName : WideString;
begin
  aController := TController.Create;
  aController.GetName(sName);
  Self.LabeledEdit1.Text := sName;
  aAggObj := aController as IAggInterface;
  aAggObj.GetInnerName(sName);
  Self.LabeledEdit2.Text := sName;

  aController := aAggObj as IController;
  aController.GetName(sName);
  Self.LabeledEdit3.Text := sName;
end;

procedure TForm1.BitBtn3Click(Sender: TObject);
var
  aController : IController;
  acnObj : IContainedInterface;
  sName : WideString;
begin
  aController := TController.Create;
  aController.GetName(sName);
  Self.LabeledEdit1.Text := sName;
  acnObj := aController as IContainedInterface;
  acnObj.GetContainedName(sName);
  Self.LabeledEdit4.Text := sName;

  aController := acnObj as IController;
  aController.GetName(sName);
  Self.LabeledEdit5.Text := sName;
end;

end.
