Plabon_dutta

BankAccount

Sep 22nd, 2021
837
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package BankingLibary;
  2.  
  3. import java.util.Random;
  4.  
  5. public class BankAccount {
  6.     String memberName, memberNID, accountNumber;
  7.     double accountBalance, minimumBalance;
  8.    
  9.     public BankAccount(String memberName, String memberNID, double accountBalance, double minimumBalance) {
  10.         this.memberName=memberName;
  11.         this.memberNID=memberNID;
  12.         this.accountBalance=accountBalance;
  13.         this.minimumBalance=minimumBalance;
  14.         Random rand = new Random();
  15.         accountNumber="" + 10000 + rand.nextInt(89999);
  16.     }
  17.    
  18.     public void deposit(double depAmount) {
  19.         if(depAmount>=0) {
  20.             accountBalance+=depAmount;
  21.         }
  22.         else System.out.println("Invalid Deposit Amount!");
  23.     }
  24.    
  25.     public void withdraw(double withAmount) {
  26.         if(withAmount>=0) {
  27.             if((accountBalance-withAmount)>minimumBalance) {
  28.                 accountBalance-=withAmount;
  29.             }
  30.             else System.out.println("Insufficient Balance!");
  31.         }
  32.         else System.out.println("Invalid Withdraw Amount!");
  33.     }
  34.    
  35.     public String toString() {
  36.         return memberName+"-"+accountNumber+"-"+accountBalance+"-"+minimumBalance;
  37.     }
  38. }
  39.  
RAW Paste Data