Delphi Éè¼Æģʽ£º¡¶HeadFirstÉè¼Æģʽ¡·Delphi7´úÂë
1.±»×°ÊÎÕß
{¡¶HeadFirstÉè¼Æģʽ¡·Ö®×°ÊÎģʽ }
{ ±¾µ¥ÔªÖеÄÀàΪ±»×°ÊÎÕß }
{ ±àÒ빤¾ß: Delphi7.0 }
{ E-Mail : xshlife@163.com }
unit uComponent;
interface
type
TBeverage = class(TObject) //³éÏóÒûÁÏÀà
protected
FDescription: String;
public
function GetDescription: String; virtual;
function Cost: Double; virtual; abstract;
end;
TEspresso = class(TBeverage) //Ũ¿§·ÈÒûÁÏÀà
public
constructor Create;
function Cost: Double; override;
end;
THouseBlend = class(TBeverage) //¾ßÌåHouseBlendÒûÁÏÀà
public
constructor Create;
function Cost: Double; override;
end;
TDarkRoast = class(TBeverage) //¾ßÌåDarkRoastÒûÁÏÀà
public
constructor Create;
function Cost: Double; override;
end;
implementation
{ TBeverage }
function TBeverage.GetDescription: String;
begin
Result := FDescription;
end;
{ TEspresso }
function TEspresso.Cost: Double;
begin
Result := 1.99;
end;
constructor TEspresso.Create;
begin
FDescription := 'Espresso';
end;
{ THouseBlend }
function THouseBlend.Cost: Double;
begin
Result := 0.89;
end;
constructor THouseBlend.Create;
begin
FDescription := 'House Blend Coffee';
end;
{ TDarkRoast }
function TDarkRoast.Cost: Double;
begin
Result := 0.99;
end;
constructor TDarkRoast.Create;
begin
FDescription := 'Dark Roast Coffee';
end;
end.
2.×°ÊÎÕß
{¡¶HeadFirstÉè¼Æģʽ¡·Ö®×°ÊÎģʽ }
{ ×°ÊÎÕ߼ȼ̳ÐÓÖ×éºÏ±»×°ÊÎÕß¡£¼Ì³Ð }
{ ÔÚÕâÀïµÄÒâͼÖ÷ÒªÊÇÀàÐÍÆ¥Åä —— }
{ Óë±»×°ÊÎÕßÊÇͬһÀàÐÍ¡£ }
{ ±àÒ빤¾ß: Delphi7.0 }
{ E-Mail : xshlife@163.com }
unit uDecorator;
interface
uses
uComponent;
type
TCondimentDecorator = class(TBeverage) //³éÏó×°ÊÎÕß
end;
TMocha = class(TCondimentDecorator) //¾ßÌå×°ÊÎÕߣºMocha
private
FBeverage: TBever
Ïà¹ØÎĵµ£º
ͼÏñµÄÖÐÖµÂ˲¨£¬¾ÍÊÇÔÚÒÔijһÏñËØΪÖÐÐĵÄn½×ÏñËؾØÕóÖУ¬ÕÒ³öR¡¢G¡¢B¸÷·ÖÁ¿µÄÖмäÖµÀ´·Ö±ðÌæ´ú¸ÃÏñËصÄRGBÖµ£¬´Ó¶ø´ïµ½¶ÔͼÏñÔëÉùÂ˲¨µÄÄ¿µÄ¡£ÕâÀïµÄÖмäÖµ²¢·ÇÏñËؾØÕóR¡¢G¡¢B¸÷·ÖÁ¿µÄµÄËãÊõƽ¾ùÖµ£¬¶øÊÇÏñËؾØÕóR¡¢G¡¢B¸÷·ÖÁ¿ÅÅÐòºóµÄÖÐλÊýÖµ¡£
ÏÂÃæÊÇDelphiͼÏñÖÐÖµÂ˲¨µÄÊµÏ ......
Delphi2010¼¯³ÉÁËfastMM£¬Õâ»Ø´ó¼Òµ÷ÊÔ³ÌÐòÊǵÄʱºò¿ÉÒÔ·½±ãµØ¼ì²éÄÚ´æй¶ÁË¡£
ʹÓ÷½·¨ÈçÏ£º
ÔÚprojectÖУ¬Ìí¼ÓÒ»ÐÐ ReportMemoryLeaksOnShutdown := DebugHook<>0;
DebugHook<>0 Ä¿µÄÊDZ£Ö¤µ¥¶ÀÔËÐÐexeÎļþ²»»áµ¯³öÄÚ´æй¶¿ò£¬Ô´Âë¿ÉÒÔ²»ÓÃ×¢Ê͵ô´ËÐÐ
program Project1;
uses
Forms,
......
±¾ÎÄÊÇ»ùÓÚ¡¶GDI+ÔÚDelphi³ÌÐòµÄÓ¦Óà – PhotoshopÉ«Ïà/±¥ºÍ¶È/Ã÷¶È¹¦ÄÜ¡·Ò»ÎĵÄBASMʵÓÃÐÔ¹ý³Ì£¬ÓйØʵÏÖÔÀí¿É²Î¼û¡¶GDI+ ÔÚDelphi³ÌÐòµÄÓ¦Óà -- ͼÏñ±¥ºÍ¶Èµ÷Õû¡·ºÍ¡¶GDI+ ÔÚDelphi³ÌÐòµÄÓ¦Óà -- ·ÂPhotoshopµÄÃ÷¶Èµ÷Õû¡·£¬´¿PASʵÏÖ´úÂëºÍ²âÊÔÀý×Ó´úÂë¼û¡¶GDI+ÔÚDelphi³ÌÐòµÄÓ¦Óà – Phot ......
1. ³éÏ󹤳§µÄ²úÆ·
{¡¶HeadFirstÉè¼Æģʽ¡·¹¤³§Ä£Ê½Ö®³éÏ󹤳§ }
{ ³éÏ󹤳§µÄ²úÆ· }
{ ±àÒ빤¾ß£ºDelphi7.0 }
{ E-Mail £ºxshlife@163.com }
unit uPizzaIngredient;
interface
type
TDough = class(TObject)
end;
TThinCrustDough ......
¼Ì³ÐÊÇΪÁ˱íÏÖÀàÓëÀàÖ®¼ä“ÊÇÒ»ÖÖ”¹Øϵ£¬ÊǶà̬´æÔڵĻù´¡£¬¼Ì³ÐÊÇÃæÏó¶ÔÏó±Ø²»¿ÉÉٵĻù´¡£¬Ö»Ö§³Ö·â×°¶ø²»Ö§³Ö¼Ì³ÐµÄÓïÑÔÖ»ÄܳÆΪ“»ùÓÚ¶ÔÏ󔣨Object-Based£©Ãæ·ÇÃæÏò¶ÔÏó“Object-Oriented”;
Object PascalÖ»Ö§³Öµ¥¼Ì³Ð£¬Ò²¾ÍÊÇÒ»¸öÅÉÉúÀàÖ»ÄÜÓÐÒ»¸ö»ùÀà
µ«¿ÉÒÔʵÏÖ¶à¸ö½Ó¿Ú ......