示例#1
0
 @Override
 public double transfer(
     int accountID, String accountType, int toAccountID, String toAccountType, double amount)
     throws InsufficientFunds {
   System.out.println("BankServant responding to transfer()");
   try {
     if (accountType.equalsIgnoreCase("checking")) {
       if (this.getCheckingBalance(accountID) > amount)
         return DBTools.transfer(
             dbConnection, accountID, accountType, toAccountID, toAccountType, amount);
       else throw new InsufficientFunds("Checking Account has Insufficient Funds");
     } else if (accountType.equalsIgnoreCase("savings")) {
       if (this.getSavingsBalance(accountID) > amount)
         return DBTools.transfer(
             dbConnection, accountID, accountType, toAccountID, toAccountType, amount);
       else throw new InsufficientFunds("Savings Account has Insufficient Funds");
     }
   } catch (AccountNotFound accountNotFound) {
     // Stuck in Exception Hell, puke message for now
     // TODO: Fix exception handling for multi-part calls.
     accountNotFound.getMessage();
   } catch (SQLException e) {
     System.err.println("SQL Error Reached BankServant.withdraw");
     System.err.println(e.getMessage());
   }
   return 0;
 }
示例#2
0
  @Override
  public double cashCheck(int accountID, int checkNumber, double amount) throws InsufficientFunds {
    System.out.println("BankServant responding to cashCheck()");
    try {
      if (this.getCheckingBalance(accountID) > amount)
        return DBTools.cashCheck(dbConnection, accountID, checkNumber, amount);
      else throw new InsufficientFunds("Checking Account Has Insufficient Funds for Check");
    } catch (SQLException e) {
      System.err.println("SQL Error Reached BankServant.cashCheck");
      System.err.println(e.getMessage());
    } catch (AccountNotFound accountNotFound) {
      // Stuck in Exception Hell, puke message for now
      // TODO: Fix exception handling for multi-part calls.
      accountNotFound.getMessage();
    }

    return 0;
  }