ilham_syamsuddin

Untitled

Oct 29th, 2017
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  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. @Override
  15. public void execute()
  16. {
  17. // get references to bank database and screen
  18. BankDatabase bankDatabase = getBankDatabase();
  19. Screen screen = getScreen();
  20.  
  21. // get the available balance for the account involved
  22. double availableBalance =
  23. bankDatabase.getAvailableBalance( getAccountNumber() );
  24.  
  25. // get the total balance for the account involved
  26. double totalBalance =
  27. bankDatabase.getTotalBalance( getAccountNumber() );
  28.  
  29. // display the balance information on the screen
  30. screen.displayMessageLine( "\nBalance Information:" );
  31. screen.displayMessage( " - Available balance: " );
  32. screen.displayDollarAmount( availableBalance );
  33. screen.displayMessage( "\n - Total balance: " );
  34. screen.displayDollarAmount( totalBalance );
  35. screen.displayMessageLine( "" );
  36. } // end method execute
  37. } // end class BalanceInquiry
Advertisement
Add Comment
Please, Sign In to add comment