Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class TollDatabase
- {
- private Account[] accounts;
- //private Account currentAccount;
- public TollDatabase()
- {
- accounts = new Account[ 2 ];
- accounts[ 0 ] = new Account( 12345, 54321, 10000, 12000 );
- accounts[ 1 ] = new Account( 98765, 56789, 2000, 2000 );
- }
- private Account getAccount(int accountNumber)
- {
- for ( Account currentAccount : accounts)
- {
- if(currentAccount.getAccountNumber() == accountNumber)
- return currentAccount;
- }
- return null;
- }
- public boolean authenticateUser(int userAccountNumber, int userPIN)
- {
- Account userAccount = getAccount(userAccountNumber);
- if(userAccount != null) return userAccount.validatePIN(userPIN);
- else return false;
- }
- public int getAvailableBalance(int userAccountNumber)
- {
- return getAccount(userAccountNumber).getAvailableBalance();
- }
- public int getTotalBalance(int userAccountNumber)
- {
- return getAccount(userAccountNumber).getTotalBalance();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement