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