Delphi Éè¼Æģʽ£º¡¶HeadFirstÉè¼Æģʽ¡·Delphi7´úÂë
Ä£°å·½·¨Ä£Ê½¶¨ÒåÁËÒ»¸öËã·¨¹Ç¼Ü£¬ÔÊÐí×ÓÀà¶ÔËã·¨µÄij¸ö»òijЩ²½Öè½øÐÐÖØд£¨override)¡£
1.CoffeineBeverageWithHook
{¡¶HeadFirstÉè¼Æģʽ¡·Ö®Ä£°å·½·¨Ä£Ê½ }
{ ±àÒ빤¾ß: Delphi7.0 }
{ E-Mail : xshlife@163.com }
unit uCoffeineBeverageWithHook;
interface
uses
SysUtils;
type
TCoffeineBeverageWithHook = class(TObject)
protected
procedure BoilWater;
procedure Brew; virtual; abstract;
procedure PourInCup;
procedure AddCondiments; virtual; abstract;
function CustomerWantsCondiments: Boolean; virtual; { ¹³×Ó }
public
procedure PrepareRecipe; { Ä£°å·½·¨ }
end;
TCoffeeWithHook = class(TCoffeineBeverageWithHook)
private
function GetUserInput: string;
public
procedure Brew; override;
procedure AddCondiments; override;
function CustomerWantsCondiments: Boolean; override;
end;
TTeaWithHook = class(TCoffeineBeverageWithHook)
private
function GetUserInput: string;
public
procedure Brew; override;
procedure AddCondiments; override;
function CustomerWantsCondiments: Boolean; override;
end;
implementation
{ TCoffeineBeverageWithHook }
procedure TCoffeineBeverageWithHook.BoilWater;
begin
Writeln('Boiling Water');
end;
function TCoffeineBeverageWithHook.CustomerWantsCondiments: Boolean;
begin
Result := True;
end;
procedure TCoffeineBeverageWithHook.PourInCup;
begin
Writeln('Poiling into cup');
end;
procedure TCoffeineBeverageWithHook.PrepareRecipe;
begin
BoilWater;
Brew;
PourInCup;
if CustomerWantsCondiments then
AddCondiments;
end;
{ TCoffeeWithHook }
procedure TCoffeeWithHook.AddCondiments;
begin
Writeln('Add Sugar and Milk');
end;
procedure TCoffeeWithHook.Brew;
begin
Writeln('Drip Coffee Through Filter');
end;
function TCoffeeWithHook.CustomerWantsCondiments: Boolean;
var
Answer: string;
Ïà¹ØÎĵµ£º
µÚÒ»Õ DELPHIµÄÔ×ÓÊÀ½ç
µÚ¶þÕ DELPHIÓëWIN32ʱ¿Õ
µÚÈýÕ ¶àÏß³Ì
µÚËÄÕÂ ½Ó¿Ú
µÚÎåÕÂ °ü
µÚÁùՠʼþÓëÏûÏ¢
µÚÆßÕ ×éÖ¯ÄãµÄÄ£¿é
µÚ°ËÕ ̽Ë÷Êý¾Ý¿â
µÚ¾ÅÕ ¶à²ãÌåϵ½á¹¹
µÚʮՠ²Ù×÷½çÃæÓë²Ù×÷Âß¼
µÚʮһÕ ÃæÏò¶ÔÏóÊý¾Ý¿â»ù´¡
µÚ¶þÕÂ&n ......
µÚÒ»Õ DELPHIµÄÔ×ÓÊÀ½ç
µÚ¶þÕ DELPHIÓëWIN32ʱ¿Õ
µÚÈýÕ ¶àÏß³Ì
µÚËÄÕÂ ½Ó¿Ú
µÚÎåÕÂ °ü
µÚÁùՠʼþÓëÏûÏ¢
µÚÆßÕ ×éÖ¯ÄãµÄÄ£¿é
µÚ°ËÕ ̽Ë÷Êý¾Ý¿â
µÚ¾ÅÕ ¶à²ãÌåϵ½á¹¹
µÚʮՠ²Ù×÷½çÃæÓë²Ù×÷Âß¼
µÚʮһÕ ÃæÏò¶ÔÏóÊý¾Ý¿â»ù´¡
µÚÈýÕÂ&n ......
µÚÒ»Õ DELPHIµÄÔ×ÓÊÀ½ç
µÚ¶þÕ DELPHIÓëWIN32ʱ¿Õ
µÚÈýÕ ¶àÏß³Ì
µÚËÄÕÂ ½Ó¿Ú
µÚÎåÕÂ °ü
µÚÁùՠʼþÓëÏûÏ¢
µÚÆßÕ ×éÖ¯ÄãµÄÄ£¿é
µÚ°ËÕ ̽Ë÷Êý¾Ý¿â
µÚ¾ÅÕ ¶à²ãÌåϵ½á¹¹
µÚʮՠ²Ù×÷½çÃæÓë²Ù×÷Âß¼
µÚʮһÕ ÃæÏò¶ÔÏóÊý¾Ý¿â»ù´¡
¿Õ ......
ͼÏñµÄÖÐÖµÂ˲¨£¬¾ÍÊÇÔÚÒÔijһÏñËØΪÖÐÐĵÄn½×ÏñËؾØÕóÖУ¬ÕÒ³öR¡¢G¡¢B¸÷·ÖÁ¿µÄÖмäÖµÀ´·Ö±ðÌæ´ú¸ÃÏñËصÄRGBÖµ£¬´Ó¶ø´ïµ½¶ÔͼÏñÔëÉùÂ˲¨µÄÄ¿µÄ¡£ÕâÀïµÄÖмäÖµ²¢·ÇÏñËؾØÕóR¡¢G¡¢B¸÷·ÖÁ¿µÄµÄËãÊõƽ¾ùÖµ£¬¶øÊÇÏñËؾØÕóR¡¢G¡¢B¸÷·ÖÁ¿ÅÅÐòºóµÄÖÐλÊýÖµ¡£
ÏÂÃæÊÇDelphiͼÏñÖÐÖµÂ˲¨µÄÊµÏ ......