ÍøÂç±à³Ì | Õ¾³¤Ö®¼Ò | ÍøÒ³ÖÆ×÷ | ͼÐÎͼÏó | ²Ù×÷ϵͳ | ³åÀ˱¦µä | Èí¼þ½Ìѧ | ÍøÂç°ì¹« | Óʼþϵͳ | ÍøÂ簲ȫ | ÈÏÖ¤¿¼ÊÔ | ϵͳ½ø³Ì
Firefox | IE | Maxthon | ѸÀ× | µç¿ | BitComet | FlashGet | QQ | QQ¿Õ¼ä | Vista | ÊäÈë·¨ | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
µ±Ç°Î»Öà > ÍøÕ¾½¨ÉèѧԺ > ÍøÂç±à³Ì > Delphi
Tag:×¢Èë,´æ´¢¹ý³Ì,·ÖÒ³,°²È«,ÓÅ»¯,xmlhttp,fso,jmail,application,session,·ÀµÁÁ´,stream,ÎÞ×é¼þ,×é¼þ,md5,ÂÒÂë,»º´æ,¼ÓÃÜ,ÑéÖ¤Âë,Ëã·¨,cookies,ubb,ÕýÔò±í´ïʽ,ˮӡ,Ë÷Òý,ÈÕÖ¾,ѹËõ,base64,urlÖØÐ´,ÉÏ´«,¿Ø¼þ,Web.config,JDBC,º¯Êý,ÄÚ´æ,PDF,Ç¨ÒÆ,½á¹¹,ÆÆ½â,±àÒë,ÅäÖÃ,½ø³Ì,·Ö´Ê,IIS,Apache,Tomcat,phpmyadmin,Gzip,´¥·¢Æ÷,socket
ÍøÂç±à³Ì£ºASP½Ì³Ì,ASP.NET½Ì³Ì,PHP½Ì³Ì,JSP½Ì³Ì,C#½Ì³Ì,Êý¾Ý¿â,XML½Ì³Ì,Ajax,Java,Perl,Shell,VB½Ì³Ì,Delphi,C/C++½Ì³Ì,Èí¼þ¹¤³Ì,J2EE/J2ME,ÒÆ¶¯¿ª·¢
±¾ÔÂÎÄÕÂÍÆ¼ö
.Delphi¿ØÖÆExcelµÄÖØÒªÊôÐԺͷ½·¨.
.ÐÔÄÜvs½á¹¹.
.[TButton]ÔËÐÐʱ¶¯Ì¬´´½¨ºÍɾ³ý°´.
.DelphiͼÏó½ØÈ¡±à³ÌʾÀý(3).
.Delphi±àÂë¹æ·¶.
.TChartʹÓþ­ÑéС½á.
.ÈçºÎµÃµ½Ó²ÅÌÎïÀíÐòºÅ.
.Ö±½ÓÐÞ¸ÄTWebBrowserÏÔʾÄÚÈÝ.
.DelphiÖÐʵÏÖÎļþ¿½±´µÄÈýÖÖ·½·¨.
.ÔÚDelphiÓëC++Ö®¼äʵÏÖº¯ÊýÓë¶ÔÏó.
.DelphiÊý¾Ý¿âÓ¦ÓóÌÐòÖг£¼û´íÎó.
.ÀûÓüôÌù°åʵÏÖ¸ßËÙµ¼³öÊý¾Ýµ½Ex.
.»Øµ÷º¯ÊýÓëDelphiµÄʼþÄ£ÐÍ.
.½«Dcom¶ÔÏóת»»³ÉCom+¶ÔÏóµÄÒ»ÖÖ.
.±£´æÒ³ÃæÎªMHTµÄ´úÂë.
.[PB+Delphi]Ö÷Ó¦ÓóÌÐòÓõÄÊÇPB£¬.
.BorlandµÄMIDAS¼¼Êõ.
.Delphi,±àÒëÎļþ£¨µÚ8Ò³£©.
.ÓеijÌÐò²»ÄÜÔËÐÐÓÚwin98µÄÔ­Òò.
.ÓÃDELPHI¸øOICQ¶¯ÊÖÊõ(¶þ).

DesignPatternÖ®SimpleFactory

·¢±íÈÕÆÚ£º2006-2-4


 

unit Unit2;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Controls,
  Dialogs, ExtCtrls, ShellAPI, AppEvnts, Forms;
type
  IFruitInterface = interface
    ['{D4557157-5241-4116-AA1E-87F86A884EA9}']
    procedure grow();
    procedure harvest();
    procedure plant();
  end;

type
  TApple = class(TComponent, IFruitInterface)
  private
    treeAge: Integer;
  public
    procedure grow();
    procedure harvest();
    procedure plant();
  end;

  TStrwaBerry = class(TComponent, IFruitInterface)
  private
    treeAge: Integer;
  public
    procedure grow();
    procedure harvest();
    procedure plant();
  end;
  TGrape = class(TComponent, IFruitInterface)
  private
    treeAge: Integer;
  public
    procedure grow();
    procedure harvest();
    procedure plant();
  end;

  TFruitGarden = class
  public
    class function GetFruit(const strFruit: string): IFruitInterface;
  end;

implementation
//{$R *.dfm}
procedure TApple.grow();
begin
  showmessage('Apple grow');
end;

procedure TApple.harvest();
begin
  showmessage('Apple harvest');
end;

procedure TApple.plant();
begin
  showmessage('Apple plant');
end;

procedure TStrwaBerry.grow();
begin
  showmessage('StrwaBerry plant');
end;

procedure TStrwaBerry.harvest();
begin
  showmessage('StrwaBerry plant');
end;

procedure TStrwaBerry.plant();
begin
  showmessage('StrwaBerry plant');
end;

procedure TGrape.grow();
begin
  showmessage('Grape plant');
end;

procedure TGrape.harvest();
begin
  showmessage('Grape plant');
end;

procedure TGrape.plant();
begin
  showmessage('Grape plant');
end;

class function TFruitGarden.GetFruit(const strFruit: string): IFruitInterface;
begin
  if strFruit = 'Apple' then
    Result := TApple.create(nil)
  else if strFruit = 'StrawBerry' then
    Result := TStrwaBerry.create(nil)
  else if strFruit = 'Grape' then
    Result := TGrape.create(nil)
  else
    raise Exception.Create('Cannot create ' + strFruit);
end;

end.

//test

  AFruitGarden: TFruitGarden;
  AFruit: IFruitInterface;
begin

  AFruitGarden := TFruitGarden.Create();
  try
    AFruit := AFruitGarden.GetFruit(Edit1.Text);
    AFruit.grow();
  except on FruitError: Exception do
      ShowMessage(FruitError.Message);
  end;

  FreeAndNil(AFruitGarden);
end;

ÉÏһƪ£ºDesignPatternÖ®FactoryMethod ÈËÆø:3612
ÏÂһƪ£º×Ô¶¨ÒåµÄTShockwaveflash ÈËÆø:4279
ä¯ÀÀÈ«²¿DelphiµÄÄÚÈÝ Dreamweaver²å¼þÏÂÔØ ÍøÒ³¹ã¸æ´úÂë ×£ÄãÊ¥µ®½Ú¿ìÀÖ 2009ÄêÐÂÄê¿ìÀÖ