DonIvo

03.Bank Account(Class BankAccount)

Jan 13th, 2021
938
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package BankAccount;
  2.  
  3. public class BankAccount {
  4.     private static int currentId = 1;
  5.  
  6.     private static double interestRate = 0.02;
  7.     private int id;
  8.     private double balance;
  9.  
  10.  
  11.     public BankAccount() {
  12.         this.balance = balance;
  13.         this.id = currentId++;
  14.     }
  15.  
  16.     public static void setInterestRate(double interest) {
  17.         interestRate = interest;
  18.     }
  19.  
  20.     public double getInterest(int years) {
  21.         return (this.balance * interestRate) * years;
  22.     }
  23.  
  24.     public void deposit(double amount) {
  25.          this.balance += amount;
  26.     }
  27.  
  28.     public int getId() {
  29.         return this.id;
  30.     }
  31.  
  32. }
  33.  
RAW Paste Data