°´¼üÅÌÉÏ·½Ïò¼ü ¡û »ò ¡ú ¿É¿ìËÙÉÏÏ·ҳ£¬°´¼üÅÌÉ쵀 Enter ¼ü¿É»Øµ½±¾ÊéĿ¼ҳ£¬°´¼üÅÌÉÏ·½Ïò¼ü ¡ü ¿É»Øµ½±¾Ò³¶¥²¿£¡
¡ª¡ª¡ª¡ªÎ´ÔĶÁÍꣿ¼ÓÈëÊéÇ©ÒѱãÏ´μÌÐøÔĶÁ£¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Implementing¡¡a¡¡Tax¡¡Engine¡¡and¡¡Tax¡¡Account¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Implementing¡¡a¡¡Canadian¡¡tax¡¡engine¡¡means¡¡deriving¡¡a¡¡class¡¡from¡¡BaseTaxEngine£»¡¡and¡¡that¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡means¡¡implementing¡¡the¡¡CreateTaxAccount£¨£©¡¡method¡£¡¡The¡¡implementation¡¡of¡¡the¡¡Canadian¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡tax¡¡engine¡¡will¡¡be¡¡in¡¡a¡¡new¡¡namespace£»¡¡and¡¡a¡¡good¡¡name¡¡would¡¡be¡¡Canada¡¡£¨as¡¡this¡¡is¡¡in¡¡the¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡LibTax¡¡project£»¡¡it¡¡will¡¡have¡¡a¡¡root¡¡namespace¡¡of¡¡LibTax£»¡¡so¡¡LibTax¡£Canada¡¡is¡¡the¡¡full¡¡namespace£©¡£¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡The¡¡code¡¡will¡¡not¡¡show¡¡the¡¡namespace¡¡details£»¡¡as¡¡they¡¡are¡¡implied¡£¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡The¡¡implementation¡¡is¡¡as¡¡follows£º¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Friend¡¡Class¡¡TaxEngine¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Inherits¡¡BaseTaxEngine¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Public¡¡Overrides¡¡Function¡¡CreateTaxAccount£¨£©¡¡As¡¡ITaxAccount¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Return¡¡New¡¡TaxAccount£¨£©¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡¡¡Function¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Page¡¡205¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡CH¡¡AP¡¡T¡¡E¡¡R¡¡¡¡¡¡7¡¡¡¡¡¡¡ö¡¡¡¡¡¡¡¡L¡¡E¡¡AR¡¡N¡¡IN¡¡G¡¡¡¡¡¡AB¡¡O¡¡U¡¡T¡¡¡¡¡¡CO¡¡M¡¡P¡¡O¡¡N¡¡E¡¡N¡¡TS¡¡¡¡¡¡AN¡¡D¡¡¡¡¡¡C¡¡L¡¡AS¡¡S¡¡¡¡H¡¡I¡¡E¡¡R¡¡AR¡¡C¡¡HI¡¡E¡¡S¡¡183¡¡
End¡¡Class¡¡
¡¡¡¡¡¡¡¡¡¡In¡¡the¡¡implementation¡¡of¡¡the¡¡CreateTaxAccount£¨£©¡¡method£»¡¡the¡¡TaxAccount¡¡class¡¡is¡¡instan
tiated¡£¡¡TaxAccount¡¡is¡¡a¡¡class¡¡that¡¡derives¡¡from¡¡BaseTaxAccount¡¡and¡¡thus¡¡implements¡¡the¡¡ITaxAccount¡¡¡¡
interface¡£¡¡The¡¡implementation¡¡of¡¡TaxAccount¡¡is¡¡as¡¡follows£º¡¡
Friend¡¡Class¡¡TaxAccount¡¡
¡¡¡¡¡¡¡¡Inherits¡¡BaseTaxAccount¡¡
¡¡¡¡¡¡¡¡Private¡¡_province¡¡As¡¡Province¡¡
¡¡¡¡¡¡¡¡Private¡¡_year¡¡As¡¡Integer¡¡
¡¡¡¡¡¡¡¡Public¡¡Overrides¡¡Function¡¡GetTaxRate£¨ByVal¡¡ine¡¡As¡¡Double£©¡¡As¡¡Double¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡If¡¡_year¡¡=¡¡2008¡¡Then¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡If¡¡_province¡¡=¡¡Province¡£Ontario¡¡Then¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Return¡¡OntarioTax2008¡£TaxRate£¨ine£©¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡If¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡If¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Throw¡¡New¡¡NotSupportedException£¨¡¨Year¡¡¡¨¡¡&¡¡_year¡¡&¡¡¡¨¡¡Province¡¡¡¨¡¡&¡¡_¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡_province¡¡&¡¡¡¨¡¡not¡¡supported¡¨£©¡¡
¡¡¡¡¡¡¡¡End¡¡Function¡¡
End¡¡Class¡¡
¡¡¡¡¡¡¡¡¡¡The¡¡purpose¡¡of¡¡the¡¡GetTaxRate£¨£©¡¡method¡¡is¡¡to¡¡return¡¡the¡¡applicable¡¡tax¡¡rate¡¡for¡¡the¡¡given¡¡¡¡
amount¡£¡¡In¡¡Canada£»¡¡the¡¡tax¡¡rate¡¡is¡¡determined¡¡by¡¡which¡¡province¡¡you¡¡live¡¡in¡¡and¡¡the¡¡year¡£¡¡The¡¡¡¡
calculation¡¡in¡¡GetTaxRate£¨£©¡¡has¡¡the¡¡ability¡¡to¡¡calculate¡¡the¡¡taxes¡¡for¡¡the¡¡year¡¡2008¡¡in¡¡the¡¡Ontario¡¡¡¡
province¡£¡¡Here¡¯s¡¡the¡¡skeleton¡¡of¡¡the¡¡OntarioTax2008¡¡class£º¡¡
Public¡¡Class¡¡OntarioTax2008¡¡
¡¡¡¡¡¡¡¡Public¡¡Shared¡¡Function¡¡TaxRate£¨ByVal¡¡ine¡¡As¡¡Double£©¡¡As¡¡Double¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡'¡¡Return¡¡the¡¡appropriate¡¡rate¡¡
¡¡¡¡¡¡¡¡End¡¡Function¡¡
End¡¡Class¡¡
¡¡¡¡¡¡¡¡¡¡Yet¡¡there¡¡is¡¡a¡¡problem£»¡¡and¡¡it¡¡involves¡¡the¡¡data¡¡members¡¡_province¡¡and¡¡_year¡£¡¡The¡¡data¡¡¡¡
members¡¡are¡¡used¡¡in¡¡the¡¡calculation¡¡GetTaxRate£¨£©£»¡¡but¡¡they¡¡are¡¡not¡¡assigned¡£¡¡This¡¡is¡¡a¡¡problem¡£¡¡
Assigning¡¡State¡¡When¡¡the¡¡Interface¡¡Cannot¡¡
The¡¡problem¡¡of¡¡the¡¡Canadian¡¡tax¡¡account¡¡is¡¡a¡¡mon¡¡one¡¡that¡¡you¡¡will¡¡encounter¡¡in¡¡many¡¡¡¡
situations¡£¡¡The¡¡essence¡¡of¡¡the¡¡problem¡¡is¡¡the¡¡need¡¡to¡¡assign¡¡state¡¡that¡¡is¡¡specific¡¡to¡¡an¡¡imple
mentation¡¡without¡¡violating¡¡the¡¡intention¡¡of¡¡the¡¡general¡¡interface¡£¡¡
¡¡¡¡¡¡¡¡¡¡To¡¡illustrate¡¡the¡¡problem£»¡¡let¡¯s¡¡say¡¡that¡¡the¡¡method¡¡GetTaxRate£¨£©¡¡will¡¡include¡¡a¡¡reference¡¡¡¡
to¡¡the¡¡province¡¡and¡¡year¡£¡¡The¡¡rewritten¡¡¡¡ITaxAccount¡¡interface¡¡would¡¡be¡¡as¡¡follows£º¡¡
Public¡¡Interface¡¡ITaxAccount¡¡¡¡
¡¡¡¡¡¡¡¡Sub¡¡AddDeduction£¨ByVal¡¡deduction¡¡As¡¡ITaxDeduction£©¡¡
¡¡¡¡¡¡¡¡Sub¡¡AddIne£¨ByVal¡¡ine¡¡As¡¡ITaxIne£©¡¡
¡¡¡¡¡¡¡¡Function¡¡GetTaxRate£¨ByVal¡¡ine¡¡As¡¡Double£»¡¡ByVal¡¡province¡¡As¡¡Province£»¡¡_¡¡
¡¡¡¡¡¡¡¡ByVal¡¡year¡¡As¡¡Integer£©¡¡As¡¡Double¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Page¡¡206¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
184¡¡¡¡¡¡¡¡¡¡¡¡¡¡CH¡¡AP¡¡T¡¡E¡¡R¡¡¡¡¡¡7¡¡¡¡¡¡¡ö¡¡¡¡¡¡¡¡L¡¡E¡¡A¡¡R¡¡N¡¡IN¡¡G¡¡¡¡¡¡AB¡¡OU¡¡T¡¡¡¡¡¡CO¡¡M¡¡P¡¡O¡¡N¡¡E¡¡N¡¡TS¡¡¡¡¡¡AN¡¡D¡¡¡¡C¡¡L¡¡AS¡¡S¡¡¡¡H¡¡I¡¡E¡¡R¡¡AR¡¡C¡¡H¡¡IE¡¡S¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ReadOnly¡¡Property¡¡Deductions£¨£©¡¡As¡¡ITaxDeduction£¨£©¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ReadOnly¡¡Property¡¡Ine£¨£©¡¡As¡¡ITaxIne£¨£©¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Interface¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡The¡¡bolded¡¡code¡¡illustrates¡¡the¡¡added¡¡parameters¡¡that¡¡are¡¡used¡¡to¡¡calculate¡¡Canadian¡¡taxes¡£¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡But¡¡is¡¡this¡¡a¡¡good¡¡solution£¿¡¡No£»¡¡it¡¯s¡¡a¡¡particularly¡¡bad¡¡solution¡£¡¡The¡¡parameters¡¡are¡¡specific¡¡to¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡an¡¡implementation£»¡¡and¡¡particularly¡¡to¡¡a¡¡Canadian¡¡implementation¡£¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡The¡¡parameter¡¡year¡¡could¡¡be¡¡justified¡¡because¡¡most¡¡countries¡¡do¡¡have¡¡specific¡¡tax¡¡rates¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡and¡¡implementations¡¡that¡¡are¡¡dependent¡¡on¡¡a¡¡year¡£¡¡Yet¡¡the¡¡parameter¡¡province¡¡has¡¡no¡¡justifi
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡cation¡£¡¡Imagine¡¡trying¡¡to¡¡implement¡¡a¡¡British¡¡tax¡¡system¡¡and¡¡needing¡¡to¡¡specify¡¡a¡¡province£»¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡when¡¡Britain¡¡does¡¡not¡¡collect¡¡ine¡¡tax¡¡at¡¡a¡¡local¡¡level¡£¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡A¡¡solution¡¡might¡¡be¡¡to¡¡redefine¡¡the¡¡interface¡¡as¡¡follows£º¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Public¡¡Class¡¡Specifics¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Public¡¡CanadianProvince¡¡As¡¡Province¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Public¡¡AmericanState¡¡As¡¡State¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Class¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Public¡¡Interface¡¡ITaxAccount¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Sub¡¡AddDeduction£¨ByVal¡¡deduction¡¡As¡¡ITaxDeduction£©¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Sub¡¡AddIne£¨ByVal¡¡ine¡¡As¡¡ITaxIne£©¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Function¡¡GetTaxRate£¨ByVal¡¡ine¡¡As¡¡Double£»¡¡ByVal¡¡year¡¡As¡¡Integer£»¡¡_¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ByVal¡¡specifics¡¡As¡¡Specifics£©¡¡As¡¡Double¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ReadOnly¡¡Property¡¡Deductions£¨£©¡¡As¡¡ITaxDeduction£¨£©¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ReadOnly¡¡Property¡¡Ine£¨£©¡¡As¡¡ITaxIne£¨£©¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Interface¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡This¡¡new¡¡implementation¡¡has¡¡a¡¡specifics¡¡parameter£»¡¡which¡¡is¡¡of¡¡type¡¡¡¡Specifics¡£¡¡The¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡purpose¡¡of¡¡Specifics¡¡is¡¡to¡¡define¡¡a¡¡class¡¡that¡¡is¡¡a¡¡hodgepodge¡¡of¡¡information¡¡that¡¡is¡¡needed¡¡to¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡determine¡¡the¡¡correct¡¡tax¡¡rate¡£¡¡However£»¡¡the¡¡Specifics¡¡approach¡¡is¡¡wrong£»¡¡for¡¡the¡¡following¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡reasons£º¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡o¡¡¡¡It¡¡requires¡¡knowing¡¡the¡¡implementation£»¡¡which¡¡in¡¡the¡¡case¡¡of¡¡the¡¡interface¡¡is¡¡a¡¡bad¡¡idea¡£¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡It¡¡is¡¡like¡¡going¡¡to¡¡a¡¡restaurant¡¡and¡¡saying¡¡you¡¡would¡¡like¡¡a¡¡waitress¡¡with¡¡blond¡¡hair¡£¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡o¡¡¡¡Even¡¡if¡¡the¡¡type¡¡Specifics¡¡were¡¡acceptable£»¡¡you¡¡would¡¡be¡¡adding¡¡and¡¡removing¡¡data¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡members¡¡depending¡¡on¡¡how¡¡many¡¡tax¡¡systems¡¡you¡¡have¡¡implemented¡£¡¡That¡¡is¡¡a¡¡bad¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡idea¡¡and¡¡introduces¡¡maintenance¡¡issues¡£¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡The¡¡proposed¡¡solutions¡¡are¡¡not¡¡acceptable¡£¡¡Additionally£»¡¡there¡¡is¡¡still¡¡the¡¡problem¡¡of¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡having¡¡to¡¡figure¡¡out¡¡which¡¡tax¡¡rate¡¡to¡¡use¡£¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Implementing¡¡Ideas¡¡with¡¡Specifics¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡To¡¡implement¡¡a¡¡solution£»¡¡let¡¯s¡¡first¡¡start¡¡by¡¡fixing¡¡the¡¡TaxAccount¡¡class¡£¡¡The¡¡modified¡¡version¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡will¡¡have¡¡some¡¡type¡¡of¡¡functionality¡¡that¡¡has¡¡data¡¡members¡¡that¡¡reference¡¡the¡¡year¡¡and¡¡prov
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ince¡£¡¡Here¡¡is¡¡the¡¡modified¡¡and¡¡correct¡¡implementation¡¡of¡¡TaxAccount£º¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Page¡¡207¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡CH¡¡AP¡¡T¡¡E¡¡R¡¡¡¡¡¡7¡¡¡¡¡¡¡ö¡¡¡¡¡¡¡¡L¡¡E¡¡AR¡¡N¡¡IN¡¡G¡¡¡¡¡¡AB¡¡O¡¡U¡¡T¡¡¡¡¡¡CO¡¡M¡¡P¡¡O¡¡N¡¡E¡¡N¡¡TS¡¡¡¡¡¡AN¡¡D¡¡¡¡¡¡C¡¡L¡¡AS¡¡S¡¡¡¡H¡¡I¡¡E¡¡R¡¡AR¡¡C¡¡HI¡¡E¡¡S¡¡185¡¡
Friend¡¡Class¡¡TaxAccount¡¡¡¡
¡¡¡¡¡¡¡¡Inherits¡¡BaseTaxAccount¡¡
¡¡¡¡¡¡¡¡Private¡¡_province¡¡As¡¡Province¡¡
¡¡¡¡¡¡¡¡Private¡¡_year¡¡¡¡As¡¡Integer¡¡
¡¡¡¡¡¡¡¡Public¡¡Sub¡¡New¡¡£¨ByVal¡¡province¡¡As¡¡Province£»¡¡ByVal¡¡year¡¡As¡¡Integer£©¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡_province¡¡=¡¡province¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡_year¡¡=¡¡year¡¡
¡¡¡¡¡¡¡¡End¡¡Sub¡¡
¡¡¡¡¡¡¡¡Public¡¡Overrides¡¡Function¡¡GetTaxRate£¨ByVal¡¡ine¡¡As¡¡Double£©¡¡¡¡As¡¡Double¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡If¡¡_year¡¡=¡¡2008¡¡Then¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡If¡¡_province¡¡=¡¡Province¡£Ontario¡¡Then¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Return¡¡OntarioTax2008¡£TaxRate£¨ine£©¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡If¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡If¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Throw¡¡New¡¡NotSupportedException£¨¡¨Year¡¡¡¨¡¡&¡¡_year¡¡&¡¡¡¨¡¡Province¡¡¡¨¡¡&¡¡_¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡_province¡¡&¡¡¡¨¡¡not¡¡supported¡¨£©¡¡
¡¡¡¡¡¡¡¡End¡¡Function¡¡
End¡¡Class¡¡
¡¡¡¡¡¡¡¡¡¡The¡¡fix¡¡is¡¡to¡¡add¡¡a¡¡constructor¡¡that¡¡has¡¡province¡¡and¡¡year¡¡as¡¡parameters¡£¡¡This¡¡sort¡¡of¡¡fix¡¡is¡¡¡¡
quite¡¡mon£»¡¡in¡¡that¡¡you¡¡don¡¯t¡¡change¡¡the¡¡interfaces£»¡¡rather¡¡you¡¡change¡¡how¡¡the¡¡implemen
tations¡¡are¡¡instantiated¡£¡¡Remember¡¡that¡¡when¡¡you¡¡instantiate¡¡a¡¡specific¡¡implementation£»¡¡you¡¡¡¡
know¡¡what¡¡functionality¡¡you¡¡want£»¡¡and¡¡thus¡¡can¡¡give¡¡the¡¡additional¡¡parameters¡£¡¡Once¡¡you¡¡are¡¡¡¡
at¡¡the¡¡interface¡¡level£»¡¡you¡¡should¡¡need¡¡to¡¡use¡¡only¡¡general¡¡ideas¡£¡¡¡¡
¡¡¡¡¡¡¡¡¡¡Now¡¡the¡¡TaxEngine¡¡class¡¡needs¡¡to¡¡be¡¡fixed¡£¡¡TaxEngine¡¡is¡¡responsible¡¡for¡¡instantiating¡¡¡¡
TaxAccount£»¡¡and¡¡thus¡¡to¡¡instantiate¡¡a¡¡Canadian¡¡TaxAccount£»¡¡TaxEngine¡¡needs¡¡additional¡¡¡¡
parameters£»¡¡as¡¡follows£º¡¡
Friend¡¡Class¡¡TaxEngine¡¡¡¡
¡¡¡¡¡¡¡¡Inherits¡¡BaseTaxEngine¡¡
¡¡¡¡¡¡¡¡Public¡¡Overrides¡¡Function¡¡CreateTaxAccount£¨£©¡¡As¡¡ITaxAccount¡¡¡¡