Delphi Éè¼ÆÄ£Ê½£º¡¶HeadFirstÉè¼ÆÄ£Ê½¡·Delphi7´úÂë
1. ¸´ÔÓµÄ×Óϵͳ
unit uSubObject;
interface
type
{ TAmplifierÓëTTuner£¬TCDPlayer£¬TDVDPlayerÏ໥ÒÀÀµ¡£ }
{ ÔÚTTunerµÈµÄ¼òµ¥ÊµÏÖʱÓò»µ½¶ÔTAmplifierµÄÒýÓ㬠}
{ µ«ÏÖʵÉú»îÖоÍÓ¦¸ÃÈÃTAmplifierÌṩ·þÎñ£¬ËùÒÔÕâÀï±£ÁôÁË¡£ }
{ TProjector¶ÔTDVDPlayerµÄÒýÓÃÒ²ÊÇͬÑùµÀÀí¡£ }
{ ǰÖÃTAmplifierÒ²¿ÉÒÔ£¬°ÑTAmplifierµÄÉùÃ÷·ÅÔÚTTunerµÈÉùÃ÷µÄºóÃæ }
TTuner = class;
TCDPlayer = class;
TDVDPlayer = class;
TAmplifier = class(TObject)
private
FTuner: TTuner;
FCD : TCDPlayer;
FDVD: TDVDPlayer;
FDescription: String;
public
constructor Create(aDescription: String);
procedure Open;
procedure Off;
procedure SetStereoSound;
procedure SetSurroundSound;
procedure SetVolume(aLevel: Integer);
procedure SetTuner (aTuner: TTuner);
procedure SetCD (aCD : TCDPlayer);
procedure SetDVD(aDVD: TDVDPlayer);
function ToString: String;
end;
TTuner = class(TObject)
private
FAmplifier: TAmplifier;
FDescription: String;
FFrequency: Double;
public
constructor Create(aDescription: String; aAmplifier: TAmplifier);
procedure Open;
procedure Off;
procedure SetAm;
procedure SetFm;
procedure SetFrequency(aFrequency: Double);
function ToString: String;
end;
TCDPlayer = class(TObject)
private
FAmplifier: TAmplifier;
FDescription: String;
FCurrentTrack: Integer;
FTitle: String;
public
constructor Create(aDescription: String; aAmplifier: TAmplifier);
procedure Open;
procedure Off;
procedure Eject;
procedure Play(aTitle: String ); overload;
procedure Play(aTrack: Integer); overload;
procedure Stop;
procedure Pause;
function ToString: String;
end;
TDVDPlayer = class(TObject)
private
FAmplifier: TAmplifier;
FDescription:
Ïà¹ØÎĵµ£º
ÉèÖÃͼÏñ¹Ø¼üÑÕÉ«£¬Ê¹Í¼ÏñµÄijÖÖ»òij¸ö·¶Î§µÄÑÕÉ«³ÉΪ͸Ã÷É«£¬ÊÇͼƬºÏ³É¡¢¶¯»ÏÔʾÖо³£ÓõÄͼÏñ´¦ÀíÊֶΡ£ÏÂÃæÊÇʵÏÖ´úÂ룺
¹ý³Ì¶¨Ò壺
// ÉèÖÃÉ«¼ü£¨Í¸Ã÷·¶Î§£©¡£colorLow µÍÉ«¼üÖµ; colorHigh ¸ßÉ«¼üÖµ
// µ±ÏñËØA¡¢R¡¢G¡¢Bֵͬʱ´óÓÚµÈÓÚcolorLowºÍСÓÚµÈÓÚcolorHighʱΪ͸Ã÷É«
procedu ......
Delphi2010¼¯³ÉÁËfastMM£¬Õâ»Ø´ó¼Òµ÷ÊÔ³ÌÐòÊǵÄʱºò¿ÉÒÔ·½±ãµØ¼ì²éÄÚ´æÐ¹Â¶ÁË¡£
ʹÓ÷½·¨ÈçÏ£º
ÔÚprojectÖУ¬Ìí¼ÓÒ»ÐÐ ReportMemoryLeaksOnShutdown := DebugHook<>0;
DebugHook<>0 Ä¿µÄÊDZ£Ö¤µ¥¶ÀÔËÐÐexeÎļþ²»»áµ¯³öÄÚ´æÐ¹Â¶¿ò£¬Ô´Âë¿ÉÒÔ²»ÓÃ×¢Ê͵ô´ËÐÐ
program Project1;
uses
Forms,
......
µ±È»Óû§ÒªÏëͨ¹ýÊý¾Ýä¯ÀÀ²¿¼þ±à¼ÐÞ¸ÄÊý¾Ý¿â±íÖеļǼ×Ö¶Îʱ£¬»¹ÒªÊܵ½ÆäËüÒòËØµÄÖÆÔ¼¡£³ýÁËÊý¾Ýä¯ÀÀ²¿¼þ±¾ÉíµÄReadOnlyÊôÐÔÉèÖÃΪFalseÍ⣬»¹ÒªÉèÖÃÆäÏàÓ¦µÄ×ֶβ¿¼þºÍÊý¾Ý¼¯²¿¼þµÄCanModifyÊôÐÔTrueÐÔ£»ÉèÖÃTDataSource²¿¼þµÄAutoEditÊôÐÔΪTrue£¬Èç¹ûÊý¾Ý¿â±íÊÇSQLÊý¾Ý¿â·þÎñÆ÷ÖеÄÊý¾ ......
ÈÝÆ÷µÄÖ÷ÒªÖ°ÔðÓÐÁ½¸ö£º´æ·ÅÔªËØºÍä¯ÀÀÔªËØ¡£¸ù¾Ýµ¥Ò»Ö°ÔðÔÔò£¨SRP£©Òª½«¶þÕß·Ö¿ª£¬ÓÚÊǽ«ä¯ÀÀ¹¦ÄÜ´ò°ü·â×°¾ÍÓÐÁ˵ü´úÆ÷¡£
Óõü´úÆ÷·â×°¶Ô¶¯Ì¬Êý×éµÄ±éÀú£º
1.ÈÝÆ÷ÖеÄÔªËØÀà
{¡¶HeadFirstÉè¼ÆÄ£Ê½¡·Ö®µü´úÆ÷ģʽ }
{ ÈÝÆ÷ÖеÄÔªËØÀà ......
1.²ßÂÔÀà
{¡¶HeadFirstÉè¼ÆÄ£Ê½¡·Ö®²ßÂÔģʽ }
{ ±¾µ¥ÔªÖеÄÀàΪ²ßÂÔÀà }
{ ±àÒ빤¾ß: Delphi7.0 }
{ E-Mail : xshlife@163.com }
unit uStrategy;
interface
type
{·ÉÐнӿڣ¬¼°ÆäʵÏÖÀà }
IFlyBehavior = Interface(IInterface)
procedure Fly;
......