document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. public class BankDatabase
  2. {
  3.     private Account[] accounts;
  4.    
  5.     public BankDatabase()
  6.     {
  7.        accounts = new Account[ 2 ];
  8.        accounts[ 0 ] = new Account( 12345, 54321, 1000.0, 1200.0 );
  9.        accounts[ 1 ] = new Account( 98765, 56789, 200.0, 200.0 );
  10.     }
  11.    
  12.     private Account getAccount(int accountNumber)
  13.     {
  14.         for ( Account currentAccount : accounts)
  15.         {
  16.             if(currentAccount.getAccountNumber() == accountNumber)
  17.             return currentAccount;
  18.         }
  19.         return null;
  20.     }
  21.    
  22.     public boolean authenticateUser(int userAccountNumber, int userPIN)
  23.     {
  24.         Account userAccount = getAccount(userAccountNumber);
  25.        
  26.         if(userAccount != null) return userAccount.validatePIN(userPIN);
  27.        
  28.         else return false;
  29.     }
  30.    
  31.     public double getAvailableBalance(int userAccountNumber)
  32.     {
  33.         return 0f;
  34.     }
  35.    
  36.     public double getTotalBalance(int userAccountNumber)
  37.     {
  38.         return getAccount(userAccountNumber).getTotalBalance();
  39.        
  40.     }
  41.    
  42.     public void credit(int userAccountNumber, double amount)
  43.     {
  44.         getAccount(userAccountNumber).credit(amount);
  45.     }
  46.    
  47.     public void debit(int userAccountNumber, double amount)
  48.     {
  49.         getAccount(userAccountNumber).debit(amount);
  50.     }
  51.    
  52. }
');