ilham_syamsuddin

Untitled

Oct 29th, 2017
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. //BankDatabase.java
  2. //represents the bank account information database
  3.  
  4. public class BankDatabase
  5. {
  6. private Account[] accounts; // array of accounts
  7.  
  8. //no- argumnet database constructor initializes account
  9. public BankDatabase()
  10. {
  11. accounts = new Account[ 2 ]; // just two accounts for testing
  12. accounts[ 0 ] = new Account( 12345,54321,1000.0, 1200.0);
  13. accounts[ 1 ] = new Account( 98765,56789,200.0, 200.0);
  14. } //end of method BankDatabase constructor
  15.  
  16. //retrieve Account object containing specified account number
  17. private Account getAccount( int accountNumber )
  18. {
  19. // loop through accounts searching for matching account number
  20. for ( Account currentAccount : accounts )
  21. {
  22. // return current account if match found
  23. if ( currentAccount.getAccountNumber() == accountNumber )
  24. return currentAccount;
  25. } // end for
  26.  
  27. return null; // if no matching account was found, return null
  28. } // end methot getAccount
  29.  
  30. //determine whether user-specified account number and PIN
Add Comment
Please, Sign In to add comment