Сţµç×ÓÊé > ÆäËûµç×ÓÊé > VB2008´ÓÈëÃŵ½¾«Í¨(PDF¸ñʽӢÎÄ°æ) >

µÚ56ÕÂ

VB2008´ÓÈëÃŵ½¾«Í¨(PDF¸ñʽӢÎÄ°æ)-µÚ56ÕÂ

С˵£º VB2008´ÓÈëÃŵ½¾«Í¨(PDF¸ñʽӢÎÄ°æ) ×ÖÊý£º ÿҳ3500×Ö

°´¼üÅÌÉÏ·½Ïò¼ü ¡û »ò ¡ú ¿É¿ìËÙÉÏÏ·­Ò³£¬°´¼üÅÌÉ쵀 Enter ¼ü¿É»Øµ½±¾ÊéĿ¼ҳ£¬°´¼üÅÌÉÏ·½Ïò¼ü ¡ü ¿É»Øµ½±¾Ò³¶¥²¿£¡
¡ª¡ª¡ª¡ªÎ´ÔĶÁÍꣿ¼ÓÈëÊéÇ©ÒѱãÏ´μÌÐøÔĶÁ£¡






Class¡¡Oven¡¡

¡¡¡¡¡¡¡¡Private¡¡_temperature¡¡As¡¡Integer¡¡



¡¡¡¡¡¡¡¡Public¡¡Sub¡¡SetTemperature£¨ByVal¡¡temperature¡¡As¡¡Integer£©¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡_temperature¡¡=¡¡temperature¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡If¡¡¡¡_temperature¡¡¡¡100¡£0¡¡Then¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Throw¡¡New¡¡Exception£¨¡¨100¡£0¡¡verification¡¡failed¡¨£©¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡If¡¡

¡¡¡¡¡¡¡¡End¡¡Sub¡¡

¡¡¡¡¡¡¡¡Public¡¡Function¡¡AreYouPreHeated£¨£©¡¡As¡¡Boolean¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡'¡¡Check¡¡if¡¡oven¡¡temperature¡¡matches¡¡prescribed¡¡temperature¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡Return¡¡False¡¡

¡¡¡¡¡¡¡¡End¡¡Function¡¡

End¡¡Class¡¡



¡¡¡¡¡¡¡¡¡¡The¡¡bolded¡¡code¡¡illustrates¡¡a¡¡verification¡¡much¡¡like¡¡that¡¡used¡¡in¡¡CurrencyTrader£»¡¡which¡¡¡¡

verifies¡¡the¡¡parameter¡¡temperature¡¡for¡¡a¡¡specific¡¡value¡£¡¡While¡¡the¡¡verification¡¡is¡¡useful¡¡for¡¡a¡¡¡¡

particular¡¡test£»¡¡it¡¡is¡¡not¡¡useful¡¡in¡¡the¡¡big¡¡picture¡£¡¡As¡¡the¡¡code¡¡is¡¡written£»¡¡the¡¡only¡¡valid¡¡value¡¡of¡¡¡¡

temperature¡¡is¡¡100¡£0£»¡¡anything¡¡else¡¡will¡¡generate¡¡an¡¡exception¡£¡¡It¡¡is¡¡definitely¡¡not¡¡a¡¡solution¡£¡¡

¡¡¡¡¡¡¡¡¡¡To¡¡get¡¡around¡¡this¡¡problem£»¡¡you¡¡could¡¡use¡¡Visual¡¡Basic¡¡conditional¡¡statements¡£¡¡Condi

tional¡¡statements¡¡are¡¡special¡¡keywords¡¡that¡¡allow¡¡a¡¡developer¡¡to¡¡define¡¡whether¡¡a¡¡piece¡¡of¡¡¡¡

source¡¡code¡¡is¡¡piled¡£¡¡Following¡¡is¡¡an¡¡example¡¡of¡¡source¡¡code¡¡that¡¡includes¡¡conditional¡¡¡¡

statements¡£¡¡



Class¡¡TestCurrencyTrader¡¡

¡¡¡¡¡¡¡¡Inherits¡¡CurrencyTrader¡¡

¡¡¡¡¡¡¡¡Public¡¡Sub¡¡InitializeExchangeRate£¨£©¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ExchangeRate¡¡=¡¡100¡£0¡¡

#If¡¡INTEGRATE_TESTS¡¡Then¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡if¡¡¡¡ExchangeRate¡¡¡¡100¡£0¡¡Then¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Throw¡¡New¡¡Exception£¨¡¨100¡£0¡¡verification¡¡failed¡¨£©¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡If¡¡

#End¡¡If¡¡

¡¡¡¡¡¡¡¡End¡¡Sub¡¡

End¡¡Class¡¡



¡¡¡¡¡¡¡¡¡¡The¡¡conditional¡¡statement¡¡always¡¡starts¡¡with¡¡a¡¡hash¡¡character¡¡£¨#£©£»¡¡immediately¡¡followed¡¡¡¡

by¡¡a¡¡keyword¡ªIf¡¡in¡¡this¡¡example¡£¡¡Between¡¡the¡¡#If¡¡and¡¡#End¡¡If¡¡is¡¡code¡¡that¡¡is¡¡conditionally¡¡¡¡

piled¡£¡¡This¡¡is¡¡known¡¡as¡¡a¡¡preprocessor¡¡directive¡£¡¡In¡¡this¡¡example£»¡¡the¡¡condition¡¡means¡¡¡¡

to¡¡pile¡¡the¡¡code¡¡contained¡¡within¡¡the¡¡#If¡¡and¡¡#End¡¡If¡¡block¡¡if¡¡the¡¡value¡¡¡¡INTEGRATE_TESTS¡¡¡¡

is¡¡true¡£¡¡

¡¡¡¡¡¡¡¡¡¡You¡¡can¡¡define¡¡a¡¡pilation¡¡identifier¡¡like¡¡¡¡INTEGRATE_TESTS¡¡in¡¡the¡¡source¡¡code¡¡or¡¡in¡¡your¡¡¡¡

IDE¡£¡¡In¡¡Visual¡¡Basic¡¡Express£»¡¡you¡¡can¡¡assign¡¡INTEGRATE_TESTS¡¡as¡¡follows£º¡¡


¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­Page¡¡172¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­

150¡¡¡¡¡¡¡¡¡¡¡¡¡¡CH¡¡AP¡¡T¡¡E¡¡R¡¡¡¡¡¡6¡¡¡¡¡¡¡ö¡¡¡¡¡¡¡¡L¡¡E¡¡A¡¡R¡¡N¡¡IN¡¡G¡¡¡¡¡¡T¡¡HE¡¡¡¡¡¡B¡¡AS¡¡IC¡¡S¡¡¡¡O¡¡F¡¡¡¡¡¡OB¡¡J¡¡E¡¡CT¡¡OR¡¡I¡¡E¡¡N¡¡T¡¡E¡¡D¡¡¡¡¡¡P¡¡R¡¡O¡¡G¡¡R¡¡AM¡¡M¡¡IN¡¡G¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡1¡£¡¡¡¡Right¡­click¡¡your¡¡project¡¡and¡¡select¡¡Properties¡£¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡2¡£¡¡¡¡Select¡¡the¡¡pile¡¡tab¡£¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡3¡£¡¡¡¡Click¡¡the¡¡Advanced¡¡pile¡¡Options¡¡button¡£¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡4¡£¡¡¡¡Add¡¡the¡¡¡¡INTEGRATE_TESTS¡¡value¡¡to¡¡the¡¡Custom¡¡Constants¡¡text¡¡box¡£¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Using¡¡Partial¡¡Classes¡¡for¡¡Verification¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Conditional¡¡pilation¡¡is¡¡useful¡¡when¡¡you¡¡want¡¡to¡¡include¡¡or¡¡remove¡¡code¡¡depending¡¡on¡¡a¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡configuration¡£¡¡However£»¡¡some¡¡programmers¡¡will¡¡frown¡¡upon¡¡having¡¡conditional¡¡pilation¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡code¡¡within¡¡a¡¡function£»¡¡as¡¡that¡¡would¡¡be¡¡a¡¡maintenance¡¡nightmare¡£¡¡Another¡¡solution¡¡is¡¡to¡¡use¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡the¡¡Partial¡¡class¡¡keyword¡¡in¡¡conjunction¡¡with¡¡conditional¡¡pilation¡¡statements¡£¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Thus¡¡far¡¡in¡¡all¡¡of¡¡the¡¡examples£»¡¡whenever¡¡we¡¡defined¡¡a¡¡class£»¡¡all¡¡of¡¡the¡¡methods¡¡and¡¡code¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡were¡¡declared¡¡between¡¡the¡¡Class/End¡¡Class¡¡pair¡£¡¡By¡¡using¡¡partial¡¡classes£»¡¡it¡¡is¡¡possible¡¡to¡¡declare¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡a¡¡class¡¡in¡¡multiple¡¡places¡£¡¡When¡¡the¡¡Visual¡¡Basic¡¡piler¡¡piles¡¡the¡¡source¡¡code£»¡¡the¡¡individual¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡class¡¡pieces¡¡will¡¡be¡¡assembled¡¡into¡¡a¡¡single¡¡class¡¡definition¡£¡¡For¡¡our¡¡test¡¡code£»¡¡we¡¡can¡¡create¡¡an¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡implementation¡¡partial¡¡class¡¡and¡¡a¡¡conditionally¡¡piled¡¡test¡¡partial¡¡class¡¡implementation¡£¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡The¡¡following¡¡is¡¡the¡¡modified¡¡TestCurrencyTrader¡¡class¡¡that¡¡could¡¡be¡¡used¡¡to¡¡test¡¡the¡¡state¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡without¡¡exposing¡¡the¡¡state¡£¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Partial¡¡Class¡¡TestCurrencyTrader¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Inherits¡¡CurrencyTrader¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Public¡¡Sub¡¡InitializeExchangeRate£¨£©¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ExchangeRate¡¡=¡¡100¡£0¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Sub¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Class¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡#if¡¡¡¡INTEGRATE_TESTS¡¡Then¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Partial¡¡Class¡¡TestCurrencyTrader¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Inherits¡¡CurrencyTrader¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Public¡¡Sub¡¡VerifyExchangeRate£¨ByVal¡¡value¡¡As¡¡Double£©¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡If¡¡ExchangeRate¡¡¡¡value¡¡Then¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Throw¡¡New¡¡Exception£¨¡¨ExchangeRate¡¡verification¡¡failed¡¨£©¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡If¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Sub¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Class¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡#End¡¡If¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡The¡¡keyword¡¡¡¡Partial¡¡prefixes¡¡the¡¡Class¡¡keyword¡£¡¡The¡¡first¡¡implementation¡¡of¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡TestCurrencyTrader¡¡is¡¡an¡¡example¡¡of¡¡not¡¡exposing¡¡state¡£¡¡The¡¡second¡¡implementation¡¡of¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡TestCurrencyTrader£»¡¡which¡¡is¡¡declared¡¡in¡¡the¡¡context¡¡of¡¡a¡¡conditional¡¡pilation¡¡statement£»¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡contains¡¡the¡¡method¡¡VerifyExchangeRate£¨£©¡£¡¡This¡¡is¡¡a¡¡verification¡¡method¡¡that¡¡tests¡¡the¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ExchangeRate¡¡property¡¡for¡¡a¡¡particular¡¡value¡£¡¡


¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­Page¡¡173¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡CH¡¡A¡¡PT¡¡E¡¡R¡¡¡¡¡¡6¡¡¡¡¡¡¡ö¡¡¡¡¡¡¡¡L¡¡E¡¡A¡¡R¡¡N¡¡I¡¡N¡¡G¡¡¡¡¡¡T¡¡HE¡¡¡¡¡¡B¡¡AS¡¡IC¡¡S¡¡¡¡O¡¡F¡¡¡¡¡¡O¡¡B¡¡J¡¡E¡¡CT¡¡OR¡¡I¡¡E¡¡N¡¡TE¡¡D¡¡¡¡¡¡P¡¡R¡¡O¡¡G¡¡R¡¡AM¡¡M¡¡IN¡¡G¡¡151¡¡



¡öNote¡¡¡¡You¡¡can¡¡use¡¡partial¡¡classes¡¡only¡¡in¡¡the¡¡context¡¡of¡¡a¡¡single¡¡assembly£»¡¡as¡¡the¡¡Partial¡¡keyword¡¡cannot¡¡¡¡

be¡¡used¡¡across¡¡assembly¡¡boundaries¡£¡¡When¡¡I¡¡say¡¡¡°single¡¡assembly£»¡±¡¡I¡¡am¡¡referring¡¡to¡¡the¡¡piled¡¡pieces¡¡of¡¡¡¡

¡¡source¡¡code¡¡illustrated¡¡in¡¡Chapter¡¡1¡£¡¡In¡¡other¡¡words£»¡¡if¡¡you¡¡define¡¡a¡¡partial¡¡class¡¡in¡¡a¡¡library£»¡¡then¡¡all¡¡¡¡

pieces¡¡of¡¡the¡¡partial¡¡class¡¡need¡¡to¡¡be¡¡defined¡¡in¡¡the¡¡library¡£¡¡¡¡



¡¡¡¡¡¡¡¡¡¡Partial¡¡classes¡¡make¡¡it¡¡simple¡¡to¡¡separate¡¡functionality¡¡into¡¡various¡¡source¡¡code¡¡files¡£¡¡This¡¡¡¡

example¡¡demonstrates¡¡using¡¡partial¡¡classes¡¡to¡¡manipulate¡¡internal¡¡state¡¡of¡¡a¡¡class¡¡without¡¡¡¡

violating¡¡the¡¡do¡­not¡­expose¡­internal¡­state¡¡rule¡£¡¡Another¡¡use¡¡of¡¡partial¡¡classes¡¡is¡¡in¡¡the¡¡context¡¡¡¡

of¡¡code¡¡generators£»¡¡where¡¡one¡¡source¡¡code¡¡file¡¡contains¡¡the¡¡custom¡¡code£»¡¡and¡¡the¡¡other¡¡source¡¡¡¡

code¡¡file¡¡contains¡¡the¡¡generator¡¡code¡£¡¡¡¡



¡öNote¡¡¡¡Only¡¡one¡¡part¡¡of¡¡a¡¡partial¡¡class¡¡needs¡¡to¡¡be¡¡explicitly¡¡qualified¡¡as¡¡Partial¡£¡¡The¡¡piler¡¡is¡¡smart¡¡¡¡

enough¡¡to¡¡realize¡¡that¡¡if¡¡it¡¡sees¡¡one¡¡part¡¡as¡¡Partial£»¡¡then¡¡all¡¡the¡¡other¡¡parts¡¡must¡¡also¡¡be¡¡partial¡¡£¨even¡¡if¡¡they¡¡¡¡

aren¡¯t¡¡explicitly¡¡qualified¡¡with¡¡the¡¡Partial¡¡keyword£©¡£¡¡



Finishing¡¡the¡¡Base¡¡Class¡¡



The¡¡ExchangeRate¡¡property¡¡is¡¡one¡¡of¡¡the¡¡pieces¡¡of¡¡shared¡¡functionality¡£¡¡Another¡¡piece¡¡of¡¡shared¡¡¡¡

functionality¡¡we¡¡want¡¡to¡¡implement¡¡is¡¡the¡¡calculation¡¡of¡¡the¡¡exchange¡¡rate¡£¡¡We¡¯ll¡¡do¡¡this¡¡with¡¡¡¡

ConvertValue£¨£©¡¡and¡¡ConvertValueInverse£¨£©¡¡methods£»¡¡which¡¡convert¡¡a¡¡currency¡¡from¡¡one¡¡value¡¡¡¡

to¡¡another¡¡using¡¡multiplication¡¡or¡¡division¡£¡¡The¡¡following¡¡shows¡¡the¡¡methods¡¡in¡¡the¡¡pleted¡¡¡¡

base¡¡class¡¡implementation¡¡of¡¡CurrencyTrader¡£¡¡



Public¡¡MustInherit¡¡Class¡¡CurrencyTrader¡¡

¡¡¡¡¡¡¡¡Private¡¡_exchangeRate¡¡As¡¡Double¡¡



¡¡¡¡¡¡¡¡Protected¡¡Property¡¡ExchangeRate£¨£©¡¡As¡¡Double¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Get¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Return¡¡_exchangeRate¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Get¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Set¡¡£¨ByVal¡¡Value¡¡As¡¡Double£©¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡_exchangeRate¡¡=¡¡Value¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Set¡¡

¡¡¡¡¡¡¡¡End¡¡Property¡¡

¡¡¡¡¡¡¡¡Protected¡¡Function¡¡ConvertValue£¨ByVal¡¡input¡¡As¡¡Double£©¡¡As¡¡Double¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Return¡¡_exchangeRate¡¡*¡¡input¡¡

¡¡¡¡¡¡¡¡End¡¡Function¡¡

¡¡¡¡¡¡¡¡Protected¡¡Function¡¡ConvertValueInverse£¨ByVal¡¡input¡¡As¡¡Double£©¡¡As¡¡Double¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Return¡¡input¡¡/¡¡_exchangeRate¡¡

¡¡¡¡¡¡¡¡End¡¡Function¡¡

End¡¡Class¡¡


¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­Page¡¡174¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­¡­

152¡¡¡¡¡¡¡¡¡¡¡¡¡¡CH¡¡AP¡¡T¡¡E¡¡R¡¡¡¡¡¡6¡¡¡¡¡¡¡ö¡¡¡¡¡¡¡¡L¡¡E¡¡A¡¡R¡¡N¡¡IN¡¡G¡¡¡¡¡¡T¡¡HE¡¡¡¡¡¡B¡¡AS¡¡IC¡¡S¡¡¡¡O¡¡F¡¡¡¡¡¡OB¡¡J¡¡E¡¡CT¡¡OR¡¡I¡¡E¡¡N¡¡T¡¡E¡¡D¡¡¡¡¡¡P¡¡R¡¡O¡¡G¡¡R¡¡AM¡¡M¡¡IN¡¡G¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡The¡¡bolded¡¡code¡¡highlights¡¡the¡¡methods¡¡that¡¡convert¡¡the¡¡currency¡¡from¡¡one¡¡unit¡¡to¡¡another¡£¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Notice¡¡that¡¡there¡¡is¡¡no¡¡declaration¡¡of¡¡specific¡¡currency¡¡units£»¡¡because¡¡the¡¡base¡¡class¡¡is¡¡a¡¡utility¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡class¡¡used¡¡to¡¡help¡¡us¡¡realize¡¡an¡¡active¡¡trader¡¡or¡¡hotel¡¡trader¡¡implementation¡£¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡öNote¡¡¡¡Base¡¡class¡¡functionality£»¡¡even¡¡when¡¡appearing¡¡trivial£»¡¡is¡¡defined¡¡to¡¡ensure¡¡consistency¡¡in¡¡implemen

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡tation¡£¡¡Without¡¡consistency£»¡¡you¡¡encounter¡¡the¡¡problem¡¡where¡¡one¡¡implementation¡¡does¡¡one¡¡thing¡¡and¡¡another¡¡¡¡

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡implementation¡¡does¡¡something¡¡pletely¡¡different¡£¡¡¡¡



¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡This¡¡pletes¡¡our¡¡test¡¡code¡£¡¡Now¡¡we¡¡will¡¡implement¡¡the¡¡active¡¡trader¡¡and¡¡hotel¡¡trader¡¡

·µ»ØĿ¼ ÉÏÒ»Ò³ ÏÂÒ»Ò³ »Øµ½¶¥²¿ ÔÞ£¨2£© ²È£¨2£©

Äã¿ÉÄÜϲ»¶µÄ