home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2002 September
/
Chip_2002-09_cd1.bin
/
zkuste
/
delphi
/
kolekce
/
d56
/
XMLCOMP.ZIP
/
test
/
model
/
DnPerson.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
2002-06-16
|
2KB
|
71 lines
unit DnPerson;
interface
uses
Classes, Contnrs, DnAddress;
type
TPerson = class(TComponent)
private
FMiddlename: string;
FFirstname: string;
FLastname: string;
FInitials: string;
FAddress: TAddress;
function GetFullName: string;
public
constructor Create(aOwner: TComponent); override;
published
property Firstname: string read FFirstname write FFirstname;
property Middlename: string read FMiddlename write FMiddlename;
property Lastname: string read FLastname write FLastname;
property Initials: string read FInitials write FInitials;
property FullName: string read GetFullName;
property Address: TAddress read FAddress;
end;
TPersonList = class(TComponentList)
private
function GetPerson(aIndex: Integer): TPerson;
public
property Person[aIndex: Integer]: TPerson read GetPerson;
end;
implementation
{ TPerson }
constructor TPerson.Create(aOwner: TComponent);
begin
inherited;
FAddress := TAddress.Create(Self);
end;
function TPerson.GetFullName: string;
begin
result := Initials;
if Firstname <> '' then
result := result + ' ' + Firstname;
if Middlename <> '' then
result := result + ' ' + Middlename;
if Lastname <> '' then
result := result + ' ' + Lastname;
end;
{ TPersonList }
function TPersonList.GetPerson(aIndex: Integer): TPerson;
begin
Assert(Items[aIndex] is TPerson);
result := TPerson(Items[aIndex]);
end;
initialization
RegisterClasses([TPerson]);
finalization
UnregisterClasses([TPerson]);
end.