GSculerlor

BalanceInquiry.java

Oct 26th, 2017
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.28 KB | None | 0 0
  1. /**
  2.  * Represents a balance inquiry ATM transaction
  3.  */
  4.  
  5. public class BalanceInquiry extends Transaction {
  6.     // BalanceInquiry constructor
  7.     public BalanceInquiry(int userAccountNumber, Screen atmScreen, BankDatabase atmBankDatabase) {
  8.         super(userAccountNumber, atmScreen, atmBankDatabase);
  9.     } // end BalanceInquiry constructor
  10.  
  11.     // performs the transaction
  12.     @Override
  13.     public void execute() {
  14.         // get references to bank database and screen
  15.         BankDatabase bankDatabase = getBankDatabase();
  16.         Screen screen = getScreen();
  17.  
  18.         // get the available balance for the account involved
  19.         double availableBalance = bankDatabase.getAvailableBalance(getAccountNumber());
  20.  
  21.         // get the total balance for the account involved
  22.         double totalBalance = bankDatabase.getTotalBalance(getAccountNumber());
  23.  
  24.         // display the balance information on the screen
  25.         screen.displayMessageLine("\nBalance Information:");
  26.         screen.displayMessage(" - Available balance: ");
  27.         screen.displayDollarAmount(availableBalance);
  28.         screen.displayMessage("\n - Total balance: ");
  29.         screen.displayDollarAmount(totalBalance);
  30.         screen.displayMessageLine("");
  31.     } // end method execute
  32. } // end class BalanceInquiry
Advertisement
Add Comment
Please, Sign In to add comment