J.10. Class BalanceInquiryClass BalanceInquiry (Fig. J.9) inherits from transaction (line 4) and represents an ATM balance inquiry transaction. BalanceInquiry does not have any attributes of its own, but it inherits transaction attributes accountNumber, screen and bankDatabase, which are accessible through transaction's Public ReadOnly properties. The BalanceInquiry constructor (lines 710) takes arguments corresponding to these attributes and simply forwards them to transaction's constructor using MyBase.New (line 9). Figure J.9. Class BalanceInquiry represents a balance inquiry ATM transaction.
Class BalanceInquiry overrides TRansaction's MustOverride method Execute to provide a concrete implementation (lines 1329) that performs the steps involved in a balance inquiry. Lines 1516 obtain the specified Account's available balance by invoking the inherited property BankDatabaseReference's GetAvailableBalance method. Note that line 16 uses the inherited property AccountNumber is used to get the account number of the current user. Lines 1924 retrieve the specified Account's total balance. Lines 2328 display the balance information on the ATM's screen using the inherited property ScreenReference. Recall that DisplayDollarAmount takes a Decimal argument and outputs it to the screen formatted as a dollar amount. For example, if a user's available balance is 1000.5, line 25 outputs $1,000.50. Note that line 28 inserts a blank line of output to separate the balance information from subsequent output (i.e., the main menu repeated by class ATM after executing the BalanceInquiry). |