示例#1
0
  public void deposit(String accountNum, String depositAmount) {
    // actually deposits the appropriate amount into the account

    double deposit =
        Double.parseDouble(
            depositAmount); // the balance in the Account class is saved as a double so it must be
                            // converted here
    boolean accountFound = customer.addMoney(deposit, accountNum);

    if (accountFound == true) {
      // create the log file
      timestamp = date.getTime();
      String customerID = customer.returnID();
      AdminLog newTransaction =
          new AdminLog(timestamp, transaction_counter, customerID, accountNum, deposit);
      adminLogs.add(newTransaction);

      transaction_counter++;
      add_interest();
      String infoMessage = customer.builderToString();
      jf.displayInfo(infoMessage);
      try {
        saveFile(cust, DBfile);
        saveFile(adminLogs, logFile);
      } catch (IOException e) {
        e.printStackTrace();
      }
    } else {
      jf.errorMessage(
          "We cannot find that account number in our database"); // pops up an error message if the
                                                                 // account was not found
    }
    customer = null; // resets the customer and account after each transaction
    pin = null;
  }
示例#2
0
  public void transfer(String transferAmount, String accountFrom, String accountTo) {
    // actually transfers the model
    double transferDouble = Double.parseDouble(transferAmount);
    boolean accountFromFound = customer.removeMoney(transferDouble, accountFrom);
    boolean accountToFound = customer.addMoney(transferDouble, accountTo);
    if (accountFromFound == true && accountToFound == true) {
      // creates the log file
      double logAmount = -transferDouble;
      timestamp = date.getTime();
      String customerID = customer.returnID();

      AdminLog firstTransaction =
          new AdminLog(timestamp, transaction_counter, customerID, accountFrom, transferDouble);

      timestamp = date.getTime();
      AdminLog secondTransaction =
          new AdminLog(timestamp, transaction_counter, customerID, accountTo, logAmount);
      adminLogs.add(firstTransaction);
      adminLogs.add(secondTransaction);

      for (AdminLog a : adminLogs) {
        long timestampe = a.getTimestamp();
      }

      transaction_counter++;
      add_interest();
      String infoMessage = customer.transferMessage(accountFrom, accountTo, transferDouble);
      jf.displayInfo(infoMessage);
      try {
        saveFile(cust, DBfile);
        saveFile(adminLogs, logFile);
      } catch (IOException e) {
        e.printStackTrace();
      }
    } else {
      jf.errorMessage(
          "We cannot find that account number in our database"); // pops up an error message if the
                                                                 // account was not found
    }
    customer = null; // resets the customer and account after each transaction
    pin = null;
  }