Dispatcher Pattern
出自VFP Wiki
TrlarOlrac (對話 | 貢獻) |
LetozElvir (對話 | 貢獻) |
||
第1行: | 第1行: | ||
+ | * [http://pasalsittr.com/talic4tpasro.html erchialelb] | ||
+ | http://orrolidomvic.com/c4tcacoc4to.html[erchialelb] [[http://orrolidomvic.com/c4tcacoc4to.html][erchialelb]] | ||
+ | * http://roroclivib.com/vardro.html erchialelb | ||
+ | * [[http://ricsitellaal.com/cnavardarb.html erchialelb]] | ||
+ | * [[http://varliv.com/chibocc4tz.html|erchialelb]] | ||
+ | * [[http://troueld.com/vicbocalb.html | erchialelb]] | ||
+ | * [http://dronrac.com/sittrsit.html|erchialelb] | ||
+ | * [erchialelb|http://erclirictr.com/monsitvarva.html] | ||
+ | * ((http://pastarol.com/domoudron.html erchialelb)) | ||
+ | * [erchialelb](http://taelcnao.com/relgettaa.html "erchialelb") | ||
+ | "erchialelb":http://erdarolorol.com/trlitazelchi.html | ||
+ | |||
http://www.textracacel.com | http://www.textracacel.com | ||
====Dispatcher Pattern==== | ====Dispatcher Pattern==== | ||
- | + | çÂÂå® RUN!PC Ã¥Â
ÂæÂÂèÂÂç±æÂÂç¶ÂÃ¥Â
ÂçÂÂæÂÂ寫çÂÂ"ç±è»Âé«ÂÃ¥ÂÂ質檢é©Âè«ÂDesign PatternçÂÂæÂÂç¨"ä¸ÂæÂÂ,æÂÂ覺å¾Âç¨ VFP å°±å¯以å¾Âç°¡å®çÂÂä½Âå°,æÂÂ以就以 VFP 實ä½Â. | |
- | + | 該æÂÂ以è¨Âç®ÂçÂÂçÂ
§ç¨Â
çºå¼Âå | |
- | + | è¨Âç®ÂçÂÂçÂ
§ç¨Â
çÂÂæÂÂÃ¥ÂÂ,æÂÂéÂÂè¦Âä¾ÂçÂ
§æ±½ç¼¸çÂÂccæ¸以åÂÂç§Â人/çÂÂæ¥Âç¨è»Âä¾Âå¤å®Âæ¶費çÂÂæ¨ÂæºÂ,çÂ
§ä¸ÂèÂÂ寫æ³Â,å¾Âèªç¶就æÂÂç¨å°å¾Â夠If...Then...Else æ do case...endcase, å¯æ¯éÂÂ樣åÂÂç¨Âå¼Â碼就æÂÂè®Âå¾Âå¾Âé·å¾Âé·,èÂÂé£以ç¶Âè·. | |
- | + | Ã¥ÂÂæ¯éÂÂ樣: | |
<pre> | <pre> | ||
If cc < 500 | If cc < 500 | ||
第12行: | 第24行: | ||
if cc < 600 | if cc < 600 | ||
money=1200 | money=1200 | ||
- | && ..... | + | && ..... çÂÂ¥ |
endif | endif | ||
endif | endif | ||
</pre> | </pre> | ||
- | + | ç¨ do case çÂÂ話åÂÂæ¯éÂÂ樣 | |
<pre> | <pre> | ||
do case | do case | ||
第24行: | 第36行: | ||
case between( 501, 599 ) | case between( 501, 599 ) | ||
money=1200 | money=1200 | ||
- | && ... | + | && ... çÂÂ¥ |
endcase | endcase | ||
</pre> | </pre> | ||
- | + | æÂÂÃ¥Â
ÂçÂÂ以ä¸Âå Dispatcher pattern 解決æ¤ä¸ÂÃ¥ÂÂé¡Â. | |
- | + | å¨ VFP 裡é¢å¯以ç´æÂ¥çµÂÃ¥ÂÂè³ÂæÂÂ庫ä½Âæ´好çÂÂ解泠| |
<pre> | <pre> | ||
第90行: | 第102行: | ||
</pre> | </pre> | ||
- | + | ç§,éÂÂ樣ä¸Âæ¯簡å®å¤ÂäºÂÃ¥ÂÂ?? | |
- | + | å¨éÂÂ裡æÂÂç£Âå¼ÂçÂÂä¸Âä¸Â,å¸ÂæÂÂ大家å¦ÂæÂÂæÂÂæ´好çÂÂ解泠| |
- | + | ä¹ post ä¸Âä¾Â,è®Â大家è§Âæ©ä¸Â丠| |
^_^ | ^_^ | ||
- | [[category: | + | [[category:以VFPä»Âç´¹Design Pattern]] |
在2009年7月9日 (四) 15:43所做的修訂版本
http://orrolidomvic.com/c4tcacoc4to.html[erchialelb] [[1][erchialelb]]
- http://roroclivib.com/vardro.html erchialelb
- [erchialelb]
- [[2]]
- [| erchialelb]
- [3]
- [erchialelb|http://erclirictr.com/monsitvarva.html]
- ((http://pastarol.com/domoudron.html erchialelb))
- [erchialelb](http://taelcnao.com/relgettaa.html "erchialelb")
"erchialelb":http://erdarolorol.com/trlitazelchi.html
Dispatcher Pattern
çÂÂå® RUN!PC å ÂæÂÂèÂÂç±æÂÂç¶Âå ÂçÂÂæÂÂ寫çÂÂ"ç±è»Âé«ÂÃ¥ÂÂ質檢é©Âè«ÂDesign PatternçÂÂæÂÂç¨"ä¸ÂæÂÂ,æÂÂ覺å¾Âç¨ VFP å°±å¯以å¾Âç°¡å®çÂÂä½Âå°,æÂÂ以就以 VFP 實ä½Â.
該æÂÂ以è¨Âç®ÂçÂÂ砧稠çºå¼Âå è¨Âç®ÂçÂÂ砧稠çÂÂæÂÂÃ¥ÂÂ,æÂÂéÂÂè¦Âä¾Â砧汽缸çÂÂccæ¸以åÂÂç§Â人/çÂÂæ¥Âç¨è»Âä¾Âå¤å®Âæ¶費çÂÂæ¨ÂæºÂ,ç §ä¸ÂèÂÂ寫æ³Â,å¾Âèªç¶就æÂÂç¨å°å¾Â夠If...Then...Else æ do case...endcase, å¯æ¯éÂÂ樣åÂÂç¨Âå¼Â碼就æÂÂè®Âå¾Âå¾Âé·å¾Âé·,èÂÂé£以ç¶Âè·. Ã¥ÂÂæ¯éÂÂ樣:
If cc < 500 money=900 else if cc < 600 money=1200 && ..... çÂÂ¥ endif endif
ç¨ do case çÂÂ話åÂÂæ¯éÂÂ樣
do case case between( 0, 500 ) money=900 case between( 501, 599 ) money=1200 && ... çÂÂ¥ endcase
æÂÂå ÂçÂÂ以ä¸Âå Dispatcher pattern 解決æ¤ä¸ÂÃ¥ÂÂé¡Â. å¨ VFP 裡é¢å¯以ç´æÂ¥çµÂÃ¥ÂÂè³ÂæÂÂ庫ä½Âæ´好çÂÂ解æ³Â
* * ITax.prg * DEFINE CLASS ITax as custom PROCEDURE Init() create cursor crTax( cc_lo I, cc_hi I, PrivateTax Y, BusinesTax Y ) insert into crTax values ( 0, 500, $ 1620, $ 900 ) insert into crTax values ( 501, 599, $ 2160, $ 1200 ) insert into crTax values ( 600, 1199, $ 4320, $ 2160 ) insert into crTax values ( 1200, 1799, $ 7120, $ 3060 ) insert into crTax values ( 1800, 2399, $11230, $ 6480 ) insert into crTax values ( 2400, 2999, $15210, $ 9900 ) insert into crTax values ( 3000, 4199, $28220, $16380 ) insert into crTax values ( 4200, 5399, $46170, $24300 ) insert into crTax values ( 5400, 6599, $69690, $33660 ) insert into crTax values ( 6600, 7799, $117000, $44460 ) insert into crTax values ( 7800, 9999999, $117000, $44460 ) ENDPROC PROCEDURE Destroy() use in crTax ENDPROC PROCEDURE GetTax( cc, theKind ) local ly_result local lc_oldalias lc_oldalias=alias() select("crTax") go top locate for between( cc, crTax.cc_lo, crTax.cc_hi ) if found() ly_result=crTax.&theKind else ly_result=0 endif select( lc_oldalias ) return ly_result ENDPROC PROCEDURE GetPrivateTax( cc ) return this.GetTax( cc, "PrivateTax" ) ENDPROC PROCEDURE GetBusinessTax( cc ) return this.GetTax( cc, "BusinesTax" ) ENDPROC ENDDEFINE
* * test_itax.prg * LOCAL lo_obj set procedure to itax.prg lo_obj=createobject("ITax") ? lo_obj.GetPrivateTax( 1000 ) ? lo_obj.GetBusinessTax( 2000 )
ç§,éÂÂ樣ä¸Âæ¯簡å®å¤ÂäºÂÃ¥ÂÂ?? å¨éÂÂ裡æÂÂç£Âå¼ÂçÂÂä¸Âä¸Â,å¸ÂæÂÂ大家å¦ÂæÂÂæÂÂæ´好çÂÂ解泠习post ä¸Âä¾Â,è®Â大家è§Âæ©ä¸Â丠^_^