• Source
    1. public class Database_EMoney_Mandiri
    2. {
    3. private static Account[] accounts;
    4.  
    5. public Database_EMoney_Mandiri()
    6. {
    7. accounts = new Account[ 2 ];
    8. accounts[ 0 ] = new Account( 51030, 12345, 10000.0);
    9. accounts[ 1 ] = new Account( 51140, 54321, 100000.0 );
    10. }
    11.  
    12. public static 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. if ( userAccount != null )
    26. return userAccount.validatePIN( userPIN );
    27. else
    28. return false;
    29. }
    30.  
    31. public static double getSaldo( int userAccountNumber )
    32. {
    33. return getAccount( userAccountNumber ).getSaldo();
    34. }
    35.  
    36. public static void beli( int userAccountNumber, double amount )
    37. {
    38. getAccount( userAccountNumber ).beli( amount );
    39. }
    40. }