Delphi Éè¼Æģʽ£º¡¶HeadFirstÉè¼Æģʽ¡·Delphi7´úÂë
1.²ßÂÔÀà
{¡¶HeadFirstÉè¼Æģʽ¡·Ö®²ßÂÔģʽ }
{ ±¾µ¥ÔªÖеÄÀàΪ²ßÂÔÀà }
{ ±àÒ빤¾ß: Delphi7.0 }
{ E-Mail : xshlife@163.com }
unit uStrategy;
interface
type
{·ÉÐнӿڣ¬¼°ÆäʵÏÖÀà }
IFlyBehavior = Interface(IInterface)
procedure Fly;
end;
TFlyWithWings = class(TInterfacedObject, IFlyBehavior)
public
procedure Fly;
end;
TFlyNoWay = class(TInterfacedObject, IFlyBehavior)
public
procedure Fly;
end;
TFlyRocketPowered = class(TInterfacedObject, IFlyBehavior)
public
procedure Fly;
end;
{½ÐÉù½Ó¿Ú£¬¼°ÆäʵÏÖÀà}
IQuackBehavior = Interface(IInterface)
procedure Quack;
end;
TQuack = class(TInterfacedObject, IQuackBehavior)
public
procedure Quack;
end;
TMuteQuack = class(TInterfacedObject, IQuackBehavior)
public
procedure Quack;
end;
TSqueak = class(TInterfacedObject, IQuackBehavior)
public
procedure Quack;
end;
implementation
{ TFlyWithWings }
procedure TFlyWithWings.Fly;
begin
Writeln('I am flying!');
end;
{ TFlyNoWay }
procedure TFlyNoWay.Fly;
begin
Writeln('I can not fly!');
end;
{ TFlyRocketPowered }
procedure TFlyRocketPowered.Fly;
begin
Writeln('I am flying with a rocket!');
end;
{ TQuack }
procedure TQuack.Quack;
begin
Writeln('Quack');
end;
{ TMuteQuack }
procedure TMuteQuack.Quack;
begin
Writeln('<Silence>');
end;
{ TSqueak }
procedure TSqueak.Quack;
begin
Writeln('Squeak');
end;
end.
2.²ßÂÔµÄÓû§
{¡¶HeadFirstÉè¼Æģʽ¡·Ö®²ßÂÔģʽ }
{ ±¾µ¥ÔªÖеÄÀàΪ²ßÂÔµÄÓû§£¬ }
{ Ò»°ã²ßÂÔģʽÖеÄÉÏÏÂÎĽӿÚÒÑ°üº¬ÔÚÓû§ÀàÖС£}
{ ±àÒ빤¾ß: Delphi7.0 }
{ E-Mail : xshlife@163.com }
unit uDuck;
interface
uses
uStrategy;
type
{ Ѽ×Ó³éÏóÀà }
TDuck
Ïà¹ØÎĵµ£º
±¾ÎÄÊÇ»ùÓÚ¡¶GDI+ÔÚDelphi³ÌÐòµÄÓ¦Óà – PhotoshopÉ«Ïà/±¥ºÍ¶È/Ã÷¶È¹¦ÄÜ¡·Ò»ÎĵÄBASMʵÓÃÐÔ¹ý³Ì£¬ÓйØʵÏÖÔÀí¿É²Î¼û¡¶GDI+ ÔÚDelphi³ÌÐòµÄÓ¦Óà -- ͼÏñ±¥ºÍ¶Èµ÷Õû¡·ºÍ¡¶GDI+ ÔÚDelphi³ÌÐòµÄÓ¦Óà -- ·ÂPhotoshopµÄÃ÷¶Èµ÷Õû¡·£¬´¿PASʵÏÖ´úÂëºÍ²âÊÔÀý×Ó´úÂë¼û¡¶GDI+ÔÚDelphi³ÌÐòµÄÓ¦Óà – Phot ......
µ±È»Óû§ÒªÏëͨ¹ýÊý¾Ýä¯ÀÀ²¿¼þ±à¼ÐÞ¸ÄÊý¾Ý¿â±íÖеļǼ×Ö¶Îʱ£¬»¹ÒªÊܵ½ÆäËüÒòËصÄÖÆÔ¼¡£³ýÁËÊý¾Ýä¯ÀÀ²¿¼þ±¾ÉíµÄReadOnlyÊôÐÔÉèÖÃΪFalseÍ⣬»¹ÒªÉèÖÃÆäÏàÓ¦µÄ×ֶβ¿¼þºÍÊý¾Ý¼¯²¿¼þµÄCanModifyÊôÐÔTrueÐÔ£»ÉèÖÃTDataSource²¿¼þµÄAutoEditÊôÐÔΪTrue£¬Èç¹ûÊý¾Ý¿â±íÊÇSQLÊý¾Ý¿â·þÎñÆ÷ÖеÄÊý¾ ......
1. ²úÆ·Àà
{¡¶HeadFirstÉè¼Æģʽ¡·¹¤³§Ä£Ê½Ö®¼òµ¥¹¤³§ }
{ ²úÆ·Àà }
{ ±àÒ빤¾ß £ºDelphi7.0 }
{ ÁªÏµ·½Ê½ £ºxshlife@163.com }
unit uProducts;
interface
type
TPizza = class(TObject)
public
procedure Prepare; virt ......
1.Ö÷ÌâÓë¹Û²ìÕß
{¡¶HeadFirstÉè¼Æģʽ¡·Ö®¹Û²ìÕßģʽ }
{ Ö÷ÌâÓë¹Û²ìÕß }
{ ±àÒ빤¾ß £ºDelphi7.0 }
{ ÁªÏµ·½Ê½ £ºxshlife@163.com }
unit uWeatherReport;
interface
uses
Classes, SysUtils;
type
TObserver = class; { ForwardÉùÃ÷£¬´´½¨Á½¸öÏà ......
¼Ì³ÐÊÇΪÁ˱íÏÖÀàÓëÀàÖ®¼ä“ÊÇÒ»ÖÖ”¹Øϵ£¬ÊǶà̬´æÔڵĻù´¡£¬¼Ì³ÐÊÇÃæÏó¶ÔÏó±Ø²»¿ÉÉٵĻù´¡£¬Ö»Ö§³Ö·â×°¶ø²»Ö§³Ö¼Ì³ÐµÄÓïÑÔÖ»ÄܳÆΪ“»ùÓÚ¶ÔÏ󔣨Object-Based£©Ãæ·ÇÃæÏò¶ÔÏó“Object-Oriented”;
Object PascalÖ»Ö§³Öµ¥¼Ì³Ð£¬Ò²¾ÍÊÇÒ»¸öÅÉÉúÀàÖ»ÄÜÓÐÒ»¸ö»ùÀà
µ«¿ÉÒÔʵÏÖ¶à¸ö½Ó¿Ú ......