end;
function tgrape.plant: string;
begin
result:='葡萄已经种好了......';
end;
{ ********** tapple ********** }
function tapple.grow: string;
begin
result:='苹果正在生长......';
end;
function tapple.harvest: string;
begin
result:='苹果可以收获了......';
end;
function tapple.plant: string;
begin
result:='苹果已经种好了......';
end;
{ ********** tstrawberry ********** }
function tstrawberry.grow: string;
begin
result:='草莓正在生长......';
end;
function tstrawberry.harvest: string;
begin
result:='草莓可以收获了......';
end;
function tstrawberry.plant: string;
begin
result:='草莓已经种好了......';
end;
{ ********** tfruitgardener ********** }
class function tfruitgardener.factory(whichfruit:string): ifruit;
begin
//精髓就是这条语句了 result:= tapple.create()
//不明白赶紧去复习复习什么是多态性
if(lowercase(whichfruit)='apple')then result:=tapple.create()
else if(lowercase(whichfruit)='grape')then result:=tgrape.create()
else if(lowercase(whichfruit)='strawberry')then result:=tstrawberry.create()