Ejemplo n.º 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;
 }
Ejemplo n.º 2
0
 @Override
 public boolean checkPIN(int accountID, String PIN) throws AccountNotFound {
   System.out.println("BankServant responding to checkPIN()");
   try {
     return DBTools.checkPIN(dbConnection, accountID, PIN);
   } catch (SQLException e) {
     throw new AccountNotFound("AccountID not found for this PIN");
   }
 }
Ejemplo n.º 3
0
 @Override
 public Customer getAccount(int accountID) throws AccountNotFound {
   System.out.println("BankServant responding to getAccount()");
   try {
     return DBTools.getAccount(dbConnection, accountID);
   } catch (SQLException e) {
     throw new AccountNotFound("AccountID Not Found");
   }
 }
Ejemplo n.º 4
0
 @Override
 public int getAccountID(String SSN) throws AccountNotFound {
   System.out.println("BankServant responding to getAccountID()");
   try {
     return DBTools.getAccountID(dbConnection, SSN);
   } catch (SQLException e) {
     throw new AccountNotFound("Account not associated with this SSN");
   }
 }
Ejemplo n.º 5
0
 @Override
 public int createAccount(Customer newCustomer) throws AccountAlreadyExist {
   System.out.println("BankServant responding to createAccount()");
   try {
     return DBTools.addAccount(dbConnection, newCustomer);
   } catch (SQLException e) {
     throw new AccountAlreadyExist("Account could not be created, could possibly exist already");
   }
 }
Ejemplo n.º 6
0
 @Override
 public String[] getTransactions(int accountID) throws AccountNotFound {
   System.out.println("BankServant responding to getTransactions()");
   try {
     return DBTools.getTransactions(dbConnection, accountID);
   } catch (SQLException e) {
     System.out.println(e.getMessage());
     throw new AccountNotFound("AccountID Not Found");
   }
 }
Ejemplo n.º 7
0
 @Override
 public boolean checkAccount(int accountID) {
   System.out.println("BankServant responding to checkAccount()");
   try {
     return DBTools.checkAccount(dbConnection, accountID);
   } catch (SQLException e) {
     System.out.println("SQL Error Reached BankServant.checkAccount()");
     e.getMessage();
   }
   return false;
 }
Ejemplo n.º 8
0
 @Override
 public boolean login(String userID, String PIN) {
   System.out.println("BankServant responding to login()");
   try {
     return DBTools.verifyUser(dbConnection, userID, PIN);
   } catch (SQLException e) {
     System.err.println("SQL Error Reached BankServant.login");
     System.err.println(e.getMessage());
   }
   return false;
 }
Ejemplo n.º 9
0
  // TODO: Add AccountNotFound Exception.
  @Override
  public double deposit(int accountID, String accountType, double amount) {
    System.out.println("BankServant responding to deposit()");
    try {
      return DBTools.deposit(dbConnection, accountID, accountType, amount);
    } catch (SQLException e) {
      System.err.println("SQL Error Reached BankServant.deposit");
      System.err.println(e.getMessage());
    }

    return 0;
  }
Ejemplo n.º 10
0
 @Override
 public double getSavingsBalance(int accountID) throws AccountNotFound {
   System.out.println("BankServant responding to getSavingsBalance()");
   try {
     System.out.println("BankServant responding to getSavingsBalance()");
     return DBTools.getSavingsBalance(dbConnection, accountID);
   } catch (SQLException e) {
     System.err.println("Caught SQLException in getSavingsBalance()");
     System.err.println(e.getMessage());
     throw new AccountNotFound("AccountID was not found");
   }
 }
Ejemplo n.º 11
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;
  }