Findryan

Untitled

Dec 9th, 2016
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. public class Account
  2. {
  3. private int accountNumber; // account number
  4. private int pin; // PIN for authentication
  5. private double availableBalance; // funds available for withdrawal
  6. private double totalBalance; // funds available + pending deposits
  7.  
  8. // Account constructor initializes attributes
  9. public Account(int theAccountNumber, int thePIN, double theAvailableBalance, double theTotalBalance){
  10. accountNumber = theAccountNumber;
  11. pin = thePIN;
  12. availableBalance = theAvailableBalance;
  13. totalBalance = theTotalBalance;
  14. } // end Account constructor
  15.  
  16. // determines whether a user-specified PIN matches PIN in Account
  17. public boolean validatePIN(int userPIN){
  18. if(userPIN == pin){
  19. return true; // means the PIN input is match with the user's PIN
  20. }
  21. else{
  22. return false; // means the PIN input is not match with the user's PIN
  23. }
  24. } // end method validatePIN
  25.  
  26. // returns available balance
  27. public double getAvailableBalance(){
  28. return availableBalance;
  29. }
  30.  
  31. // returns the total balance
  32. public double getTotalBalance(){
  33. return totalBalance;
  34. }
  35.  
  36. // credits an amount to the account
  37. public void credit(double amount){
  38. totalBalance += amount; // add to total balance
  39. }
  40.  
  41. // debits an amount from the account
  42. public void debit(double amount){
  43. availableBalance -= amount; // substract from available balance
  44. totalBalance -= amount; // substract from total balance
  45. }
  46.  
  47. // returns account number
  48. public int getAccountNumber(){
  49. return accountNumber;
  50. }
  51. } // end class Account
Add Comment
Please, Sign In to add comment