コード例 #1
0
  @Override
  public void execute() {

    BankDatabase bankDatabase = getBankDatabase();
    Screen screen = getScreen();

    double availableBalance = bankDatabase.getAvailableBalance(getAccountNumber());

    double totalBalance = bankDatabase.getTotalBalance(getAccountNumber());

    screen.displayMessageLine("\nBalance Information");
    screen.displayMessage(" - Available Balance");
    screen.displayDollarAmount(availableBalance);
    screen.displayMessage("\n - Total Balance");
    screen.displayDollarAmount(totalBalance);
    screen.displayMessageLine("");
  }
コード例 #2
0
ファイル: BalanceInquiry.java プロジェクト: pockman/ATM1
  // performs the transaction
  @Override
  public void execute() {
    // get references to bank database and screen
    BankDatabase bankDatabase = getBankDatabase();
    Screen screen = getScreen();

    // get the available balance for the account involved
    double availableBalance = bankDatabase.getAvailableBalance(getAccountNumber());

    // get the total balance for the account involved
    double totalBalance = bankDatabase.getTotalBalance(getAccountNumber());

    // display the balance information on the screen
    screen.displayMessageLine("\nBalance Information:");
    screen.displayMessage(" - Available balance: ");
    screen.displayDollarAmount(availableBalance);
    screen.displayMessage("\n - Total balance: ");
    screen.displayDollarAmount(totalBalance);
    screen.displayMessageLine("");
  } // end method execute
コード例 #3
0
ファイル: Deposit.java プロジェクト: pockman/ATM1
  // perform transaction
  @Override
  public void execute() {
    BankDatabase bankDatabase = getBankDatabase(); // get reference
    Screen screen = getScreen(); // get reference

    amount = promptForDepositAmount(); // get deposit amount from user

    // check whether user entered a deposit amount or canceled
    if (amount != CANCELED) {
      // request deposit envelope containing specified amount
      screen.displayMessage("\nPlease insert a deposit envelope containing ");
      screen.displayDollarAmount(amount);
      screen.displayMessageLine(".");

      // receive deposit envelope
      boolean envelopeReceived = depositSlot.isEnvelopeReceived();

      // check whether deposit envelope was received
      if (envelopeReceived) {
        screen.displayMessageLine(
            "\nYour envelope has been "
                + "received.\nNOTE: The money just deposited will not "
                + "be available until we verify the amount of any "
                + "enclosed cash and your checks clear.");
        // credit account to reflect the deposit
        bankDatabase.credit(getAccountNumber(), amount);
      } // end if
      else // deposit envelope not received
      {
        screen.displayMessageLine(
            "\nYou did not insert an " + "envelope, so the ATM has canceled your transaction.");
      } // end else
    } // end if
    else // user canceled instead of entering amount
    {
      screen.displayMessageLine("\nCanceling transaction...");
    } // end else
  } // end method execute