unit Unit2;

interface

type
    TPerson=class(TObject)
    private
    FAge:Integer;
    FName:string;
    FDegree:array[0..3] of string;

    function getAge: Integer;
    procedure setAge(const Value: Integer);
    function getName: string;
    procedure setName(const Value: string);
    function getDegree(mindex: Integer): string;
    procedure setDegree(mindex: Integer; const Value: string);

public
    property Age: Integer read getAge write setAge;
    property Name:string read getName write setName;
    property Degree[mindex:Integer]:string read getDegree write setDegree;
    constructor create;
end;

implementation
{ TPerson }

constructor TPerson.create();
begin
    FAge:=100;
    FName:='小明';
    FDegree[0]:='本科以下';
    FDegree[1]:='本科';
    FDegree[2]:='硕士';
    FDegree[3]:='博士及以上';
end;

function TPerson.getAge: Integer;
begin
    Result:= FAge;
end;

function TPerson.getDegree(mindex: Integer): string;
begin
    Result:=FDegree[mindex];
end;

function TPerson.getName: string;
begin
Result:=FName;
end;

procedure TPerson.setAge(const Value: Integer);
begin
FAge:=Value;
end;

procedure TPerson.setDegree(mindex: Integer; const Value: string);
begin
    FDegree[mindex]:=Value;
end;

procedure TPerson.setName(const Value: string);
begin
    FName:=Value;
end;

end.

posted on 2023-03-18 10:52  Rube's Delphi Blog  阅读(156)  评论(0)    收藏  举报