Advertisement
arafaee

Account.java

May 13th, 2017
946
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.21 KB | None | 0 0
  1. /**  
  2.   * Account.java  
  3.   *  
  4.   * @author Hafara Firdausi/ 5115100043
  5.   * @version 01  
  6.   */
  7.  
  8. public class Account
  9. {
  10.     private int accountNumber;
  11.     private int pin;
  12.     private double availableBalance;
  13.     private double totalBalance;
  14.    
  15.     public Account(int theAccountNumber, int thePIN, double theAvailableBalance, double theTotalBalance)
  16.     {
  17.         accountNumber = theAccountNumber;
  18.         pin = thePIN;
  19.         availableBalance = theAvailableBalance;
  20.         totalBalance = theTotalBalance;
  21.     }  
  22.    
  23.     public boolean validatePIN(int userPIN)
  24.     {
  25.         if(userPIN == pin)
  26.         {
  27.             return true;
  28.         }
  29.         else
  30.         {
  31.             return false;
  32.         }
  33.     }  
  34.    
  35.     public double getAvailableBalance()
  36.     {
  37.         return availableBalance;
  38.     }
  39.    
  40.     public double getTotalBalance()
  41.     {
  42.         return totalBalance;
  43.     }
  44.    
  45.     public void credit(double amount)
  46.     {
  47.         totalBalance += amount;
  48.     }
  49.    
  50.     public void debit(double amount)
  51.     {
  52.         availableBalance -= amount;
  53.         totalBalance -= amount;
  54.     }
  55.    
  56.     public int getAccountNumber()
  57.     {
  58.         return accountNumber;
  59.     }  
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement