«á¤@­¶
«e¤@­¶
¦^¥Ø¿ý
¦^­º­¶
²Ä¤G³¹¡@Delphi­±¦Vª«¥óªºµ{¦¡³]­p¤èªk¡]¤G¡^

2.1.4 ¸õÂà»y¥y¡@

Object Pascalªº¸õÂà»y¥y¦³if©Mcase¨â­Ó¡C¡@

2.1.4.1 if»y¥y¡@

        if»y¥y·|­pºâ¤@­Óªí¹F¦¡¡A¨Ã®Ú¾Ú­pºâµ²ªG¨M©wµ{¦¡¬yµ{¡C¦b¤W¤åªº¨Òµ{¤¤¡A®Ú¾ÚColorDialog.Executeªºªð¦^­È¡A¨M©wµ¡Å骺­I´ºÃC¦â¡Cif«O¯d¦r«á¸òÀH¤@­Ó²£¥ÍBoolean­ÈTrue©ÎFalseªºªí¹F¦¡¡C¤@¯ë¥Î¡§=¡¨§@¬°Ãö«Y¹Bºâ²Å¡A¤ñ¸û²£¥Í¤@­Ó¥¬º¸«¬­È¡C·íªí¹F¦¡¬°True®É¡A°õ¦æthen«áªº»y¥y¡C§_«h°õ¦æelse«áªº¥N½X¡Aif»y¥y¤]¥i¥H¤£§telse³¡¤À¡Aªí¹F¦¡¬°False®É¦Û°Ê¸õ¨ì¤U¤@¦æµ{¦¡¡C

        if»y¥y¥i¥H±_ª¬¡A·í¨Ï¥Î´_¦X»y¥yªí¹F®É¡A´_¦X»y¥y«e«á»Ý¥[¤Wbegin¡Kend¡Celse«O¯d¦r«e¤£¯à¥[¡§¡F¡¨¡A¦Ó¥B¡A½sĶ¾¹·|±Nelse»y¥yµø¬°ÄÝ©ó³Ì¾aªñªºif»y¥y¡C¥²­n®É¡A¶·¨Ï¥Îbegin¡Kend«O¯d¦r¨Ó±j­¢else³¡¤ÀÄÝ©ó¬Y¤@¯Åªºif»y¥y¡C¡@

2.1.4.2 case»y¥y¡@

         case»y¥y¾A¥Î©ó³Q§PÂ_ªºÅܼƩÎÄݩʬO¾ã§Î¡B¦r¤¸«¬¡BªTÁ|«¬©Î¤l¬É«¬®É(LongInt°£¥~)¡C¥Îcase»y¥y¶i¦æÅÞ¿è¸õÂà¤ñ½s¼g½ÆÂøªºif»y¥y®e©ö¾\Ū¡A¦Ó¥Bµ{¦¡¥N½X¾ã§Î¸û§Ö¡C

¤U­±ªº¨Òµ{Åã¥Ü¤@­Ó¨Ï¥Îcase»y¥yªºµ¡Åé¡G

«Ø¥ß¦p¤Uªº¨Æ¥ó³B²z¹Lµ{¡G¡@

procedure TForm1.Button1Click(Sender: TObject);

var

Number : Integer;

begin

Number := StrToInt(Edit1.Text);

case Number of

1,3,5,7,9: Label2.Caption := '©_¼Æ';

0,2,4,6,8: Label2.Caption := '°¸¼Æ';

10..100:

begin

Label2.Caption := '¦b10¨ì100¤§¶¡';

Form1.Color := clBlue;

end;

else

Label2.Caption := '¤j©ó100©Î¬°­t¼Æ';

end;

end;¡@

        °õ¦æµ{¦¡¡A·íEdit1³¡¥ó±µ¨ü¨ì¤@­Ó­È¡A¨Ã«ö°Ê¡§OK¡¨«ö¶sIJµoµ{¦¡«á¡ANumber«K³Q½á­È¬°¥Î¤á¿é¤Jªº¼Æ­È¡Ccase»y¥y®Ú¾ÚNumberªº­È§PÂ_¸Ó°õ¦æ­þ¤@±ø»y¥y¡C¶Hif»y¥y¤@¼Ë¡Ccase»y¥y¤]¦³¥i¿ï¾Üªºelse³¡¤À¡Ccase»y¥y¥Hendµ²§À¡C¡@

2.1.5 ¦^°é»y¥y¡@

       Object Pascalªº¦^°é»y¥y¦³¤TºØ¡Grepeat¡Bwhile©Mfor»y¥y¡C¡@

2.1.5.1 repeat»y¥y¡@

        repeat»y¥y·|­«½Æ°õ¦æ¤@¦æ©Î¤@¬q»y¥yª½¨ì¬Y¤@ª¬ºA¬°¯u¡C»y¥y¥Hrepeat¶}©l¡A¥Huntilµ²§ô¡A¨ä«á¸òÀH³Q§PÂ_ªº¥¬º¸ªí¹F¦¡¡C°Ñ¾\¥H¤Uªº¨Òµ{¡G¡@

i := 0;

repeat

i := i+1;

Writen(i);

until i=10;¡@

       ·í¦¹»y¥y³Q°õ¦æ®É¡Aµ¡Å骺¤U¤è·|¥X²{1¨ì10ªº¼Æ¦r¡C¥¬º¸ªí¹F¦¡ i=10 (ª`·N¡A»P¨ä¥L»y¨¥¤£¦Pªº¬O¡A¡§=¡¨¬OÃö«Y¹Bºâ²Å¡A¦Ó¤£¯à¶i¦æ½á­È¾Þ§@)ª½¨ìrepeat..untilµ{¦¡¬qªºµ²§À¤~·|³Q­pºâ¡A³o·N¨ýµÛrepeat»y¥y¦Ü¤Ö·|³Q°õ¦æ¤@¦¸¡C¡@

2.1.5.2 while»y¥y¡@

         while»y¥y©Mrepeat»y¥yªº¤£¦P¤§³B¬O¡A¥¦ªº¥¬º¸ªí¹F¦¡¦b¦^°éªº¶}ÀY¶i¦æ§PÂ_¡Cwhile«O¯d¦r«á­±¥²¶·¸ò¤@­Ó¥¬º¸ªí¹F¦¡¡C¦pªG¸Óªí¹F¦¡ªºµ²ªG¬°¯u¡A¦^°é³Q°õ¦æ¡A§_«h·|µ²§ô¦^°é¡A°õ¦æwhile»y¥y«á­±ªºµ{¦¡¡C

         ¤U­±ªº¨Òµ{¹F¨ì©M¤W­±ªºrepeat¨Òµ{¹F¨ì¦P¼Ëªº®ÄªG¡G¡@

i := 0;

while i<10 do

begin

i := i+1;

writeln(i);

end; ¡@

2.1.5.3 for»y¥y¡@

         for»y¥yªºµ{¦¡¥N½X·|°õ¦æ¤@©wªº¦¸¼Æ¡C¥¦»Ý­n¤@­Ó¦^°éÅܼƨӱ±¨î¦^°é¦¸¼Æ¡C±z»Ý­n±Ô­z¤@­ÓÅܼơA¥¦ªº«¬¦¡¥i¥H¬O¾ã§Î¡B¥¬º¸«¬¡B¦r¤¸«¬¡BªTÁ|«¬©Î¤l¬É«¬¡C

¤U­±ªºµ{¦¡¬q·|Åã¥Ü1¨ì5ªº¼Æ¦r¡Ai¬°±±¨îÅܼơG¡@

var

i : integer;

for i := 1 to 5 do

writeln(i);¡@

          ¥H¤W¤¶²Ð¤F¤TºØ¦^°é»y¥y¡C¦pªG±zª¾¹D¦^°é­n°õ¦æ¦h¤Ö¦¸ªº¸Ü¡A¥i¥H¨Ï¥Îfor»y¥y¡Cfor¦^°é°õ¦æ³t«×§Ö¡A®Ä²v¤ñ¸û°ª¡C¦pªG±z¤£ª¾¹D¦^°é­n°õ¦æ¦h¤Ö¦¸¡A¦ý¦Ü¤Ö·|°õ¦æ¤@¦¸ªº¸Ü¡A¿ï¥Îrepeat..until»y¥y¤ñ¸û¦X¾A¡F·í±z»{¬°µ{¦¡¥i¯à¤@¦¸³£¤£°õ¦æªº¸Ü¡A³Ì¦n¿ï¥Îwhile..do»y¥y¡C¡@

2.1.6 µ{¦¡¼Ò¸s²Õ

        µ{¦¡¼Ò¸s²Õ¦bObject Pascal¤¤¬O«Ü­«­nªº·§©À¡C¥¦­Ì´£¨Ñ¤FÀ³¥Îµ{¦¡ªºµ²ºc¡A¨M©w¤FÅܼơBÄݩʭȪº½d³ò¤Îµ{¦¡°õ¦æªº¹Lµ{¡C¥¦¥Ñ¨â­Ó³¡¤À¸s¸s²Õ¦¨¡G¥i¿ï¾Üªº±Ô­z³¡¤À©M»y¥y³¡¤À¡C¦pªG¦³±Ô­z³¡¤À¡A«h¥²¦b»y¥y³¡¤À¤§«e¡C±Ô­z³¡¤À¥]¬AÅܼƱԭz¡B±`¼Æ±Ô­z¡B«¬¦¡±Ô­z¡B¼Ð¸¹±Ô­z¡Bµ{¦¡¡A¨ç¼Æ¡A¤èªkªº±Ô­zµ¥¡C»y¥y³¡¤À±Ô­z¤F¥i°õ¦æªºÅÞ¿è¦æ°Ê¡C

        ¦bDelphi¤¤¡A³Ì±`¨£ªºµ{¦¡¼Ò¸s²Õ«K¬O¨Æ¥ó³B²z¹Lµ{¤¤ªºµ{¦¡¼Ò¸s²Õ¡C¤U­±ªº¨Æ¥ó³B²z¹Lµ{¬O§t¦³ÅܼƱԭz³¡¤Àªºµ{¦¡¼Ò¸s²Õ¡G¡@

procedure TForm.Button1Click(Sender Tobject);

var {µ{¦¡¼Ò¸s²Õªº±Ô­z³¡¤À}

Name : string;

begin {µ{¦¡¼Ò¸s²Õªº»y¥y³¡¤À}

Name := Edit1.Text;

Edit2.Text := 'Welcome to Delphi'+Name;

end; {µ{¦¡¼Ò¸s²Õµ²§ô}¡@

        ®w³æ¤¸¤]¬Oµ{¦¡¼Ò¸s²Õ¡C®w³æ¤¸ªºinterface³¡¤À§t¦³®w¨ç¼Æ¡B«¬¦¡¡B¨p¦³¡A¤½¦³Äæ¦ìªº±Ô­z¡A¤]¥i¥H§t¦³±`¼Æ¡BÅܼƪº±Ô­z¡C³o¤@³¡¤À¥i¥H§@¬°µ{¦¡¼Ò¸s²Õªº±Ô­z³¡¤À¡C¦b®w³æ¤¸ªºimplementation³¡¤À¤¤³q±`§t¦³¦UºØ¨Æ¥ó³B²z¹Lµ{¡A¥¦­Ì¥i¥Hµø¬°¼Ò¸s²Õªº»y¥y³¡¤À¡A¬O¨Æ¥ó³B²z¼Ò¸s²Õ¡C®w³æ¤¸¼Ò¸s²Õµ²§ô©ó®w³æ¤¸µ²§ôªºend.³B¡C

        µ{¦¡¼Ò¸s²Õ¤¤¥i¥H¥]§t¨ä¥Lªºµ{¦¡¼Ò¸s²Õ¡C¤W¤å®w³æ¤¸¼Ò¸s²Õ¤¤§t¦³¨Æ¥ó³B²z¼Ò¸s²Õ¡C¦Ó®w³æ¤¸¼Ò¸s²Õ¹ê»Ú¬O¦b¤uµ{µ{¦¡¼Ò¸s²Õ¤¤¡C

         ©Ò¦³ªºDelphiÀ³¥Îµ{¦¡³£¦³¬Û¦Pªº°ò¥»µ²ºc¡C·íµ{¦¡³vº¥½ÆÂø®É¡A¦bµ{¦¡¤¤¥[¤J¼Ò¸s²Õ§Y¥i¡C¨Ò¦p¦b®w³æ¤¸¼Ò¸s²Õ¤¤¥[¤J¨Æ¥ó³B²z¼Ò¸s²Õ¡A¦V¤uµ{¤¤¥[¤J®w³æ¤¸¼Ò¸s²Õµ¥¡C¼Ò¸s²Õ¤Æµ{¦¡³]­p¨Ï±oµ{¦¡µ²ºc¨}¦n¡A¨Ã¥B¹ï¼Æ¾Ú¨ã¦³«OÅ@§@¥Î¡C¡@

2.1.7 Ãö©ó§@¥Î½d³ò¡@

2.1.7.1 ¼ÐÃѲŪº§@¥Î½d³ò¡@

        ¤@­ÓÅܼơB±`¼Æ¡B¤èªk¡B«¬¦¡©Î¨ä¥L¼ÐÃѲŪº½d³ò©w¸q¤F³o­Ó¼ÐÃѲŪº¬¡°Ê°ÏÄæ¦ì¡C¹ï©ó±Ô­z³o­Ó¼ÐÃѲŪº³Ì¤pµ{¦¡¼Ò¸s²Õ¦Ó¨¥¡A¦¹¼ÐÃѲŬO§½³¡ªº¡C·í±zªºÀ³¥Îµ{¦¡¦b±Ô­z¤@­Ó¼ÐÃѲŪºµ{¦¡¼Ò¸s²Õ¥~°õ¦æ®É¡A¸Ó¼ÐÃѲŴN¤£¦b¦¹½d³ò¤º¡C³o·N¨ýµÛ¦¹®É°õ¦æªºµ{¦¡µLªk¦s¨ú³o­Ó¼ÐÃѲšA¥u¦³·íµ{¦¡¦A«×¶i¤J±Ô­z³o­Ó¼ÐÃѲŪºµ{¦¡¼Ò¸s²Õ®É¡A¤~¥i¥H¦s¨ú¥¦¡C

         ¤U­±ªº¥Ü·N¹Ïªí¥Ü¤@­Ó§t¦³¨â­Ó®w³æ¤¸ªº¤uµ{¡A¨C­Ó®w³æ¤¸¤¤¤S¦U¦³¤T­Ó¹Lµ{©Î¨Æ¥ó³B²z¹Lµ{¡C

2.1.7.2 ¦s¨ú¨ä¥Lµ{¦¡¼Ò¸s²Õ¤¤ªº±Ô­z¡@

        ±z¥i¥H¦b¥Ø«eªºµ{¦¡¼Ò¸s²Õ¤¤¦s¨ú¨ä¥Lµ{¦¡¼Ò¸s²Õ¤¤ªº±Ô­z¡C¨Ò¦p±z¦b®w³æ¤¸¤¤½s¼g¤@­Ó¨Æ¥ó³B²z¹Lµ{¨Ó­pºâ§Q²v¡A«h¨ä¥Lªº®w³æ¤¸¥i¥H¦s¨ú³o­Ó¨Æ¥ó³B²z¹Lµ{¡C­n¦s¨ú¤£¦b¥Ø«e®w³æ¤¸¤¤ªº±Ô­z¡AÀ³¦b³o­Ó±Ô­z¤§«e¥[¤W¨ä¥LÀ³¥Îµ{¦¡ªº¼Ðñ©M¤@­ÓÂI¸¹(.)¡C¨Ò¦p¡A¦b®w³æ¤¸Unit1¤¤¦³¨Æ¥ó³B²z¹Lµ{CalculateInterest¹Lµ{¡A²{¦b±z·Q¦b®w³æ¤¸Unit2¤¤©I¥s³o¤@¹Lµ{¡A«h¥i¥H¦bUnit2ªºuses¤l¥y¤¤¥[¤JUnit1¡A¨Ã¨Ï¥Î¤U­±ªº±Ô­z¡G¡@

Unit1.CalculateInterest(PrincipalInterestRate : Double)¡F¡@

        À³¥Îµ{¦¡ªº¥N½X¤£¯à¦b¤@­Ó¼Ò¸s²Õ¥~¦s¨ú¥¦±Ô­zªºÅܼơC¨Æ¹ê¤W¡A·íµ{¦¡°õ¦æ¸õ¥X¤@­Ó¼Ò¸s²Õ«á¡A³o¨ÇÅܼƴN¤£¦s¦b©ó°O¾ÐÅ餤¤F¡C³o¤@ÂI¹ï©ó¥ô¦ó¼ÐÃѲų£¬O¤@¼Ëªº¡A¤£ºÞ¨Æ¥ó³B²z¹Lµ{¡B¹Lµ{¡B¨ç¼ÆÁÙ¬O¤èªk¡A³£¨ã¦³³o¤@©Ê½è¡C³o¼Ëªº¼ÐÃѲź٬°§½³¡ÅܼơC¡@

2.1.7.3 «ö·Ó§@¥Î½d³ò±Ô­z¼ÐÃѲÅ

        ±z¥i¥H¦bÀ³¥Îµ{¦¡ªº¤£¦P¦a¤è±Ô­z¤@­Ó¼ÐÃѲšA¦Ó¥u»Ý«OÃÒ¥¦­Ìªº¦³®Ä½d³ò¤£¦P§Y¥i¡C½sĶ¾¹·|¦Û°Ê¦s¨ú³Ì¾aªñ¥Ø«e½d³òªº¼ÐÃѲšC

       ®w³æ¤¸ªº¥þ§½ÅܼƤ@¯ë¥i¥H±Ô­z¦b«O¯d¦rimplementation«á­±¡C¨Ò¦p¡A¤U­±ªº¨Òµ{¹ê²{±N¨â­Ó½s¿è®Ø¤¤ªº¾ã¼Æ¬Û¥[¡AÅã¥Ü¦b²Ä¤T­Ó½s¿è®Ø¤¤¡C¥Î¨ì¤F¤@­Ó¾ã§Îªº¥þ§½ÅܼÆCount¡G¡@

¡Kimplememntation¡@

var

Count : Integer;¡@

procedure TForm1.AddClick(Sender:TObject);

var

FirstNumber,SecondNumber:Integer;

begin

Count := Count + 1;

Counter.Text := IntToStr(Count);

FirstNumber := StrToInt(Edit1.Text);

SecondNumber := StrToInt(Edit2.Text);

Edit3.Text := IntToStr(FirstNumber+SecondNumber);

end;

¡K¡@

        ¬°¤F¹ê²{¨C«ö°Ê¤@¦¸«ö¶sCount¼W¥[¤@¦¸¡A¥²¶·¹ï¥þµ{ÅܼÆCount¶i¦æªì©l¤Æ³B²z¡C¦bµ{¦¡®w³æ¤¸ªºµ²§À³B¡A³Ì«á¤@­Óend.«O¯d¦r¤§«e¡A¥[¤J«O¯d¦rinitialization©Mªì©l¤ÆCountªº¥N½X¡G¡@

¡K

initialization

Count := 0;¡@

        ³o¼Ë·í¨Æ¥ó³B²z¹Lµ{AddClick³QIJµo®É¡ACount´N·|³Q¼W¥[¤@¦¸¡A¥Hªí©º­pºâ¦¸¼Æ¡C¦pªG¥Î­±¦Vª«¥óµ{¦¡³]­p¡A«hCount¥i¥H±Ô­z¦¨µ¡Å骺¤@­ÓÄæ¦ì¡A³o¦b¤U¤@¸`¤¤±N¦³Á¿­z¡C¡@

2.1.8 ½s¼g¤@­Ó¹Lµ{©Î¨ç¼Æ

         ¦b±z¶}µoDelphiÀ³¥Îµ{¦¡®É¡A©Ò»Ýªº¤j³¡¤À¥N½X³£½s¼g¦b¨Æ¥ó³B²z¹Lµ{¤¤¡A¦ý¦³®É¤´µM»Ý­n½s¼g¤£¬O¨Æ¥ó³B²z¹Lµ{ªº¨ç¼Æ©Î¹Lµ{¡C¨Ò¦p¡A±z¥i¥H§â¦b¦h­Ó¨Æ¥ó³B²z¹Lµ{¤¤¥Î±o¨ì»y¥y½s¼g¦¨¹Lµ{¡AµM«á¥ô¦ó¨Æ¥ó³B²z¹Lµ{¡B¹Lµ{¡B¨ç¼Æ³£¥i¥H¶H©I¥s¤w¸g¦s¦bªº¹Lµ{©Î¨ç¼Æ¤@¼Ëª½±µ©I¥s¥¦¡C¦n³B¬O±z¥u»Ý½s¼g¤@¦¸¥N½X¡A¦Ó¥Bµ{¦¡¥N½X·|¤ñ¸û²M·¡¡C

2.1.8.1 ¤@­Ó¦Û¦æ½s¼gªº¨ç¼Æ¨Òµ{¡@

        ¦b¤W¤å¨â­Ó¼Æ¬Û¥[ªºµ{¦¡¤¤¡A¦pªG½s¿è®Ø¤¤µL­È¡A«h·|¨Ï±oµ{¦¡¥X¿ù¤¤Â_¡C¬°ÁקK³oºØ±¡ªp¡A½s¼g¤U­±ªº¨ç¼Æ¡AÀˬd½s¿è®Ø¤¤¬O§_¦³­È¡A¦pµL­È¡A«h´£¿ô¥Î¤á¿é¤J¡G¡@

function NoValue(AnEditBox:TEdit):Boolean;

begin

if AnEditBox.Text='' then

begin

AnEditBox.Color := clRed;

AnEditBox.Text := '½Ð¿é¤J¾ã¼Æ­È';

Result := True;

end

else

begin

AnEditBox.Color := clWindow;

Result := False;

end;

end;¡@

        NoValue¨ç¼Æ·|Àˬd½s¿è®Ø¬O§_¬°ªÅ¡A¦pªG¬O¡A½s¿è®ØÃC¦âÅܬõ¡A¨Ã´£¿ô¥Î¤á¿é¤J¤@­Ó¾ã¼Æ¡AµM«á¨ç¼Æªð¦^¯u­È¡FResult«O¯d¦r¦bDelphi¤¤¥Î¨Ó±M«ü¨ç¼Æªð¦^­È¡C¦b¤W¤åªº¨Òµ{¤¤¥[¤JNoValue¨ç¼Æ¡G¡@

procedure TForm1.AddClick(Sender: TObject);

var

FirstNumber,SecondNumber : Integer;

begin

if NoValue(Edit1)or NoValue(Edit2) then

exit;

Count := Count + 1;

Counter.Text := IntToStr(Count);

FirstNumber := StrToInt(Edit1.Text);

SecondNumber := StrToInt(Edit2.Text);

Edit3.Text := IntToStr(FirstNumber+SecondNumber);

end;¡@

        ¦pªG¨ä¤¤ªº¥ô¦ó¤@­Óªð¦^¯u­È¡A«hªí¥Ü¦³½s¿è®ØªÅ¡A·|°õ¦æexit¹Lµ{¡A¨Ï±o¥Ø«eªºµ{¦¡¼Ò¸s²Õ°±¤î°õ¦æ¡A¨Ã¨Ï±o½s¿è®Ø¥X²{¿é­È´£¥Ü¡C·í·s­È³Q¿é¤J«á¡A¦A°õ¦æµ{¦¡®É¡A¬õ¦â´£¥Ü³QÁô¥h¡A«ì´_¥¿±`ªº­pºâª¬ºA¡C¡@

2.1.8.2 ¹Lµ{©M¨ç¼Æªº¼ÐÃD¡@

        ¨C¤@­Ó¹Lµ{©Î¨ç¼Æ³£¥H¼ÐÃD¶}©l¡A¨ä¤¤¥]¬A¹Lµ{©Î¨ç¼Æªº¼Ðñ©M¥¦¨Ï¥Îªº°Ñ¼Æ¡C¹Lµ{¥H«O¯d¦rprocedure¶}©l¡A¨ç¼Æ¥H«O¯d¦rfunction¶}©l¡C°Ñ¼Æ¦ì©ó¬A¸¹ùØ­±¡A¨C¤@­Ó°Ñ¼Æ¥H¤À¸¹¤À¹j¡C¨Ò¦p¡G¡@

procedure validateDate(Day : Integer; month : Integer; Year : Integer);

      ±z¤]¥i¥H±N¬Û¦P«¬¦¡ªº°Ñ¼Æ¸s¸s²Õ¦X¦b¤@°_¡A«h¤W­z¹Lµ{ÀY¼g§@¡G¡@

procedure ValidateDate(Day, Month, Year : Integer);¡@

       ¨ç¼Æ¦b¼ÐÃD¤¤ÁÙ¦h¤F¤@¶µ¡Gªð¦^­Èªº«¬¦¡¡C¤U­±¬O¤@­Óªð¦^­È¬°Double«¬ªº¨ç¼Æ¼ÐÃD¡G¡@

function CalculateInterest(principal,InterestRate:Double):Double;¡@

2.1.8.3 ¨ç¼Æ©M¹Lµ{¤¤ªº«¬¦¡±Ô­z¡@

       ¤@­Ó¹Lµ{©Î¨ç¼Æµ{¦¡¼Ò¸s²Õ¤]§t¦³±Ô­z³¡¤À©M»y¥y³¡¤À¡C±Ô­z³¡¤À¥i¥H¥]¬A«¬¦¡±Ô­z¡BÅܼƱԭz¡B±`¼Æ±Ô­zµ¥¡C°£¤FObject Pascal»y¨¥¤¤¤w¸g©w¸qªº«¬¦¡¤§¥~¡ADelphiªºÀ³¥Îµ{¦¡ÁÙ¥i¥H«Ø¥ß·sªº¼Æ¾Ú«¬¦¡¡C«¬¦¡±Ô­z³¡¤À¦³«O¯d¦rtype¶}©l¡C¤U­±¬O¤@¨Ç«¬¦¡ªº±Ô­z¡G¡@

type

Tcount = Integer;

TPrimaryColor = (Red,Yellow,Blue);

TTestIndex = 1..100;

TTextValue = -99..99;

TTestList = array [TTestIndex] of TTestValue;

TCharVal = Ord('A')..Ord('Z') ;

Today = (Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,

Sunday) ;¡@

         ¦b«¬¦¡¼ÐÃѲū᭱¡A¥Î¡§¡×¡¨¸¹©w¸q¤F·sªº«¬¦¡¡C«¬¦¡¬É©w¤FÅܼƪº¨ú­È½d³ò¡A¨Ò¦p¡ATCount«¬¦¡ªºÅܼƥ²¶·¬O¾ã§Î­È¡F¤@­ÓTPrimaryColor«¬¦¡ªºÅܼƥu¯à¬Ored¡Byellow©Îblueµ¥µ¥¡C¨C¤@­Ó«¬¦¡ªº¼Ðñ³£¬O¥Ñ¦r¥ÀT¶}©l¡A³o¨Ã«D¥²¶·ªº¡A¦ý¥¦¬ODelphiªººD¨Ò¡A¦b°Ï§O«¬¦¡¦W©M¼ÐÃѲŮɫD±`¦³¥Î¡C«¬¦¡±Ô­z¥i¥H¬O§½³¡ªº¡A¤]¥i¥H¬O¥þ§½ªº¡C¦pªG±z§â¥¦©ñ¦bimplementation«á­±¡A«hªí©ú¹ï©ó®w³æ¤¸¨ÓÁ¿¡A¥¦¬O¥þ§½ªº¡A©Ò¦³ªº¨Æ¥ó³B²z¹Lµ{©M¨ä¥Lªº¹Lµ{¡B¨ç¼Æ³£¥i¥H©I¥s¥¦¡C¦pªG«¬¦¡¬O¦b¹Lµ{¤¤³Q±Ô­zªº¡A«h¬O§½³¡ªº¡AÂ÷¶}³o¤@¹Lµ{¡A¸Ó«¬¦¡±N¥¢®Ä¡C

         ¤@¯ë¨ÓÁ¿¡A¦b¹Lµ{©M¨ç¼Æ¤¤¡A¥ô¦ó«¬¦¡±Ô­z³£¦bÅܼƱԭz¤§«e¡A¦Ó¥ô¦óÅܼƱԭz³£¦b±`¼Æ¤§«e¡C¦ý¬O¡A¥u­n¿í±q±Ô­z¥²¶·¦b¹Lµ{»P¨ç¼Æªº¼ÐÃD¤§«á¡A¦Ó¥B¦bµ{¦¡¥N½X¤§«e¡A§Y¬O¦³®Äªº¡C


«á¤@­¶
«e¤@­¶
¦^¥Ø¿ý
¦^­º­¶