Source of BalanceInquiry.java


  1: // BalanceInquiry.java
  2: // Represents a balance inquiry ATM transaction
  3: 
  4: public class BalanceInquiry extends Transaction
  5: {
  6:    // BalanceInquiry constructor
  7:    public BalanceInquiry( int userAccountNumber, Screen atmScreen, 
  8:       BankDatabase atmBankDatabase )
  9:    {
 10:       super( userAccountNumber, atmScreen, atmBankDatabase );
 11:    } // end BalanceInquiry constructor
 12: 
 13:    // performs the transaction
 14:    public void execute()
 15:    {
 16:       // get references to bank database and screen
 17:       BankDatabase bankDatabase = getBankDatabase();
 18:       Screen screen = getScreen();
 19: 
 20:       // get the available balance for the account involved
 21:       double availableBalance = 
 22:          bankDatabase.getAvailableBalance( getAccountNumber() );
 23: 
 24:       // get the total balance for the account involved
 25:       double totalBalance = 
 26:          bankDatabase.getTotalBalance( getAccountNumber() );
 27:       
 28:       // display the balance information on the screen
 29:       screen.displayMessageLine( "\nBalance Information:" );
 30:       screen.displayMessage( " - Available balance: " ); 
 31:       screen.displayDollarAmount( availableBalance );
 32:       screen.displayMessage( "\n - Total balance:     " );
 33:       screen.displayDollarAmount( totalBalance );
 34:       screen.displayMessageLine( "" );
 35:    } // end method execute
 36: } // end class BalanceInquiry
 37: 
 38: 
 39: 
 40: /**************************************************************************
 41:  * (C) Copyright 1992-2005 by Deitel & Associates, Inc. and               *
 42:  * Pearson Education, Inc. All Rights Reserved.                           *
 43:  *                                                                        *
 44:  * DISCLAIMER: The authors and publisher of this book have used their     *
 45:  * best efforts in preparing the book. These efforts include the          *
 46:  * development, research, and testing of the theories and programs        *
 47:  * to determine their effectiveness. The authors and publisher make       *
 48:  * no warranty of any kind, expressed or implied, with regard to these    *
 49:  * programs or to the documentation contained in these books. The authors *
 50:  * and publisher shall not be liable in any event for incidental or       *
 51:  * consequential damages in connection with, or arising out of, the       *
 52:  * furnishing, performance, or use of these programs.                     *
 53:  *************************************************************************/