°´¼üÅÌÉÏ·½Ïò¼ü ¡û »ò ¡ú ¿É¿ìËÙÉÏÏ·ҳ£¬°´¼üÅÌÉ쵀 Enter ¼ü¿É»Øµ½±¾ÊéĿ¼ҳ£¬°´¼üÅÌÉÏ·½Ïò¼ü ¡ü ¿É»Øµ½±¾Ò³¶¥²¿£¡
¡ª¡ª¡ª¡ªÎ´ÔĶÁÍꣿ¼ÓÈëÊéÇ©ÒѱãÏ´μÌÐøÔĶÁ£¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡This¡¡pletes¡¡our¡¡test¡¡code¡£¡¡Now¡¡we¡¡will¡¡implement¡¡the¡¡active¡¡trader¡¡and¡¡hotel¡¡trader¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ponents¡¡of¡¡the¡¡currency¡¡exchange¡¡application¡£¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Writing¡¡the¡¡Active¡¡Trader¡¡and¡¡Hotel¡¡Trader¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Currency¡¡Converters¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡With¡¡the¡¡TestCurrencyTrader¡¡test¡¡solution¡¡pleted£»¡¡it¡¯s¡¡time¡¡to¡¡turn¡¡our¡¡attention¡¡to¡¡the¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡CurrencyTrader¡¡solution¡£¡¡As¡¡mentioned¡¡earlier£»¡¡this¡¡consists¡¡of¡¡the¡¡active¡¡trader¡¡and¡¡hotel¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡trader¡¡currency¡¡converter¡¡ponents¡£¡¡Here£»¡¡you¡¯ll¡¡see¡¡more¡¡clearly¡¡what¡¡it¡¡means¡¡to¡¡use¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡inheritance¡£¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Implementing¡¡ActiveCurrencyTrader¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡The¡¡ActiveCurrencyTrader¡¡class¡¡implements¡¡the¡¡logic¡¡of¡¡the¡¡active¡¡currency¡¡trader¡£¡¡To¡¡begin£»¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡we¡¯ll¡¡add¡¡its¡¡constructor¡£¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Adding¡¡a¡¡Constructor¡¡to¡¡ActiveCurrencyTrader¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡To¡¡give¡¡ActiveCurrencyTrader¡¡some¡¡default¡¡state£»¡¡we¡¡use¡¡a¡¡constructor¡£¡¡However£»¡¡the¡¡constructor¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡will¡¡serve¡¡another¡¡purpose£»¡¡in¡¡that¡¡any¡¡class¡¡that¡¡instantiates¡¡ActiveCurrencyTrader¡¡will¡¡consider¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡the¡¡instance¡¡as¡¡immutable¡£¡¡Immutable¡¡means¡¡that¡¡once¡¡data¡¡has¡¡been¡¡assigned¡¡to¡¡the¡¡instance£»¡¡it¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡cannot¡¡be¡¡altered¡£¡¡In¡¡other¡¡words£»¡¡it¡¡is¡¡unchangeable¡£¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡öNote¡¡¡¡The¡¡String¡¡type¡¡is¡¡immutable¡¡because¡¡once¡¡a¡¡string¡¡variable¡¡has¡¡been¡¡assigned£»¡¡it¡¡cannot¡¡be¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡changed¡£¡¡Take¡¡a¡¡look¡¡at¡¡the¡¡methods¡¡associated¡¡with¡¡String£»¡¡and¡¡you¡¡will¡¡see¡¡nothing¡¡that¡¡allows¡¡you¡¡to¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡modify¡¡the¡¡contents¡£¡¡An¡¡immutable¡¡type¡¡is¡¡good¡¡because¡¡it¡¡allows¡¡you¡¡to¡¡implement¡¡a¡¡set¡it¡and¡forget¡it¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡object£»¡¡and¡¡it¡¡prevents¡¡other¡¡classes¡¡from¡¡accidentally¡¡changing¡¡the¡¡contents¡£¡¡Overall£»¡¡an¡¡immutable¡¡type¡¡is¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡robust¡¡and¡¡predictable¡¡£¨though¡¡they¡¡are¡¡the¡¡exception£»¡¡not¡¡the¡¡rule£»¡¡most¡¡types¡¡allow¡¡you¡¡to¡¡modify¡¡state£©¡£¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡The¡¡following¡¡shows¡¡the¡¡constructor¡¡code¡¡added¡¡to¡¡ActiveCurrencyTrader¡£¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Page¡¡175¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡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¡¡153¡¡
Public¡¡Class¡¡ActiveCurrencyTrader¡¡
¡¡¡¡¡¡¡¡Inherits¡¡CurrencyTrader¡¡
¡¡¡¡¡¡¡¡Private¡¡_fromCurrency¡¡As¡¡String¡¡
¡¡¡¡¡¡¡¡Private¡¡_toCurrency¡¡As¡¡String¡¡
¡¡¡¡¡¡¡¡Public¡¡Sub¡¡New£¨ByVal¡¡currExchange¡¡As¡¡Double£»¡¡ByVal¡¡fromCurrency¡¡As¡¡String£»¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡ByVal¡¡toCurrency¡¡As¡¡String£©¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ExchangeRate¡¡=¡¡currExchange¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡_fromCurrency¡¡=¡¡fromCurrency¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡_toCurrency¡¡=¡¡toCurrency¡¡
¡¡¡¡¡¡¡¡End¡¡Sub¡¡
End¡¡Class¡¡
¡¡¡¡¡¡¡¡¡¡The¡¡constructor¡¡has¡¡three¡¡parameters£º¡¡currExchange¡¡represents¡¡the¡¡current¡¡exchange¡¡rate£»¡¡¡¡
fromCurrency¡¡indicates¡¡the¡¡source¡¡currency¡¡£¨for¡¡example£»¡¡USD£©£»¡¡and¡¡toCurrency¡¡indicates¡¡the¡¡¡¡
destination¡¡currency¡¡£¨for¡¡example£»¡¡EUR£©¡£¡¡These¡¡three¡¡parameters¡¡are¡¡assigned¡¡to¡¡data¡¡members£»¡¡¡¡
whereby¡¡only¡¡the¡¡current¡¡exchange¡¡rate¡¡is¡¡assigned¡¡to¡¡the¡¡base¡¡class¡¡¡¡
CurrencyTrader¡£ExchangeRate¡£¡¡
Defining¡¡Informational¡¡Read¡Only¡¡Properties¡¡
The¡¡characters¡¡that¡¡represent¡¡the¡¡from¡¡currency¡¡and¡¡to¡¡currency¡¡are¡¡stored¡¡as¡¡strings£»¡¡and¡¡are¡¡¡¡
purely¡¡for¡¡informational¡¡purposes¡£¡¡For¡¡example£»¡¡let¡¯s¡¡say¡¡that¡¡you¡¡have¡¡instantiated¡¡a¡¡bunch¡¡of¡¡¡¡
currency¡¡pairs¡¡so¡¡that¡¡the¡¡trader¡¡can¡¡prehend¡¡the¡¡currency¡¡pair¡¡in¡¡which¡¡the¡¡values¡¡of¡¡¡¡
_fromCurrency¡¡and¡¡_toCurrency¡¡will¡¡be¡¡presented¡£¡¡This¡¡means¡¡that¡¡the¡¡currency¡¡strings¡¡are¡¡¡¡
read¡only¡¡properties¡¡and¡¡are¡¡coded¡¡as¡¡follows£º¡¡
Public¡¡Class¡¡ActiveCurrencyTrader¡¡
¡¡¡¡¡¡¡¡Inherits¡¡CurrencyTrader¡¡
¡¡¡¡¡¡¡¡Private¡¡_fromCurrency¡¡As¡¡String¡¡
¡¡¡¡¡¡¡¡Private¡¡_toCurrency¡¡As¡¡String¡¡
¡¡¡¡¡¡¡¡Public¡¡Sub¡¡New¡¡£¨ByVal¡¡currExchange¡¡As¡¡Double£»¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ByVal¡¡fromCurrency¡¡As¡¡String£»¡¡ByVal¡¡toCurrency¡¡As¡¡String£©¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ExchangeRate¡¡=¡¡currExchange¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡_fromCurrency¡¡=¡¡fromCurrency¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡_toCurrency¡¡=¡¡toCurrency¡¡
¡¡¡¡¡¡¡¡End¡¡Sub¡¡
¡¡¡¡¡¡¡¡Public¡¡ReadOnly¡¡Property¡¡FromCurrency£¨£©¡¡As¡¡String¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Get¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Return¡¡_fromCurrency¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Get¡¡
¡¡¡¡¡¡¡¡End¡¡Property¡¡
¡¡¡¡¡¡¡¡Public¡¡ReadOnly¡¡Property¡¡ToCurrency£¨£©¡¡As¡¡String¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Get¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Return¡¡_toCurrency¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Get¡¡
¡¡¡¡¡¡¡¡End¡¡Property¡¡
End¡¡Class¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Page¡¡176¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
154¡¡¡¡¡¡¡¡¡¡¡¡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¡¡naming¡¡of¡¡the¡¡properties¡¡£¨¡¡FromCurrency¡¡and¡¡ToCurrency£©¡¡corresponds¡¡closely¡¡to¡¡the¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡naming¡¡of¡¡the¡¡data¡¡members¡¡£¨_fromCurrency¡¡and¡¡_toCurrency£©¡£¡¡I¡¡do¡¡this¡¡throughout¡¡my¡¡code¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡so¡¡that¡¡I¡¡know¡¡what¡¡each¡¡piece¡¡of¡¡code¡¡means¡£¡¡My¡¡convention¡¡is¡¡to¡¡use¡¡a¡¡leading¡¡underscore¡¡to¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡name¡¡private¡¡data¡¡members£»¡¡but¡¡you¡¡can¡¡use¡¡a¡¡different¡¡notation¡¡if¡¡you¡¡prefer¡£¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Adding¡¡the¡¡Conversion¡¡Methods¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡The¡¡last¡¡step¡¡to¡¡make¡¡the¡¡ActiveCurrencyTrader¡¡class¡¡plete¡¡is¡¡to¡¡add¡¡the¡¡functionality¡¡to¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡convert¡¡a¡¡value¡¡from¡¡or¡¡to¡¡a¡¡currency¡¡pair¡£¡¡The¡¡ActiveCurrencyTrader¡¡class¡¡will¡¡use¡¡the¡¡exact¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡currency¡¡exchange¡¡rate¡£¡¡The¡¡ConvertValue£¨£©£»¡¡and¡¡ConvertValueInverse£¨£©¡¡methods¡¡have¡¡protected¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡scope£»¡¡and¡¡thus¡¡are¡¡not¡¡exposed¡¡outside¡¡the¡¡inheritance¡¡hierarchy¡£¡¡ActiveCurrencyTrader¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡needs¡¡to¡¡define¡¡a¡¡pair¡¡of¡¡publicly¡¡scoped¡¡methods¡¡that¡¡will¡¡call¡¡the¡¡protected¡¡scope¡¡methods¡£¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡The¡¡following¡¡is¡¡the¡¡plete¡¡ActiveCurrencyTrader¡¡implementation¡£¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Public¡¡Class¡¡ActiveCurrencyTrader¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Inherits¡¡CurrencyTrader¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Private¡¡_fromCurrency¡¡As¡¡String¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Private¡¡_toCurrency¡¡As¡¡String¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Public¡¡Sub¡¡New¡¡£¨ByVal¡¡currExchange¡¡As¡¡Double£»¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ByVal¡¡fromCurrency¡¡As¡¡String£»¡¡ByVal¡¡toCurrency¡¡As¡¡String£©¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ExchangeRate¡¡=¡¡currExchange¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡_fromCurrency¡¡=¡¡fromCurrency¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡_toCurrency¡¡=¡¡toCurrency¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Sub¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Public¡¡ReadOnly¡¡Property¡¡FromCurrency£¨£©¡¡As¡¡String¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Get¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Return¡¡_fromCurrency¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Get¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Property¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Public¡¡ReadOnly¡¡Property¡¡ToCurrency£¨£©¡¡As¡¡String¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Get¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Return¡¡_toCurrency¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Get¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Property¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Public¡¡Function¡¡ConvertTo£¨ByVal¡¡value¡¡As¡¡Double£©¡¡As¡¡Double¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Return¡¡ConvertValue£¨value£©¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Function¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Public¡¡Function¡¡ConvertFrom£¨ByVal¡¡value¡¡As¡¡Double£©¡¡As¡¡Double¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Return¡¡ConvertValueInverse£¨value£©¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Function¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡End¡¡Class¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡The¡¡ConvertTo£¨£©¡¡and¡¡ConvertFrom£¨£©¡¡methods¡¡are¡¡wrappers¡¡to¡¡the¡¡ConvertValue£¨£©¡¡and¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ConvertValueInverse£¨£©¡¡methods£»¡¡and¡¡provide¡¡no¡¡added¡¡value¡£¡¡But¡¡remember¡¡the¡¡problem¡¡of¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡the¡¡cashier¡¡and¡¡credit¡¡card¡£¡¡Just¡¡because¡¡it¡¡seems¡¡like¡¡there¡¡is¡¡no¡¡added¡¡value£»¡¡the¡¡reality¡¡is¡¡that¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡you¡¡are¡¡writing¡¡code¡¡that¡¡is¡¡acting¡¡as¡¡a¡¡gatekeeper¡¡and¡¡giving¡¡yourself¡¡flexibility¡£¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡Page¡¡177¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡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¡¡155¡¡
¡¡¡¡¡¡¡¡¡¡For¡¡example£»¡¡suppose¡¡that¡¡CurrencyTrader¡£ConvertValue£¨£©£»¡¡and¡¡CurrencyTrader¡£¡¡
ConvertValueInverse£¨£©¡¡were¡¡declared¡¡using¡¡¡¡Public¡¡rather¡¡than¡¡¡¡Protected¡£¡¡Then¡¡any¡¡user¡¡of¡¡¡¡
ActiveCurrencyTrader¡¡could¡¡use¡¡the¡¡functionality¡¡exposed¡¡by¡¡CurrencyTrader¡£¡¡Suppose¡¡someone¡¡¡¡
decided¡¡to¡¡change¡¡the¡¡functionality¡¡of¡¡ConvertValue£¨£©¡¡and¡¡ConvertValueInverse£¨£©¡£¡¡At¡¡that¡¡¡¡
point£»¡¡you¡¡would¡¡have¡¡problems£»¡¡because¡¡the¡¡changes¡¡to¡¡CurrencyTrader¡¡automatically¡¡imply¡¡¡¡
changes¡¡in¡¡ActiveCurrencyTrader¡£¡¡By¡¡defining¡¡your¡¡own¡¡methods£»¡¡you¡¡are¡¡controlling¡¡and¡¡¡¡
making¡¡sure¡¡that¡¡if¡¡things¡¡change¡¡in¡¡the¡¡future£»¡¡you¡¡can¡¡acmodate¡¡them¡¡without¡¡needing¡¡¡¡
to¡¡change¡¡the¡¡callers¡¡of¡¡ActiveCurrencyTrader¡£¡¡
¡¡¡¡¡¡¡¡¡¡We¡¡have¡¡now¡¡pleted¡¡the¡¡functionality¡¡of¡¡ActiveCurrencyTrader£»¡¡so¡¡let¡¯s¡¡implement¡¡¡¡
HotelCurrencyTrader¡£¡¡
Implementing¡¡HotelCurrencyTrader¡¡