Advertisement
Guest User

BancAccount

a guest
Oct 14th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. package BankAccount;
  2.  
  3. public class BankAccount {
  4. final private static double DEFAULT_INTEREST_VALUE = 0.02;
  5. private static int accountCount = 1;
  6. private static double interestRate = DEFAULT_INTEREST_VALUE;
  7. private static int id;
  8. private static double balance;
  9.  
  10. static void setInterestRate(double interestRate) {
  11. BankAccount.interestRate = interestRate;
  12. }
  13.  
  14. public BankAccount() {
  15. this.id = accountCount++;
  16. balance = 0;
  17. }
  18.  
  19. public static int getId() {
  20. return id;
  21. }
  22.  
  23. public static void setId(int id) {
  24. BankAccount.id = id;
  25. }
  26.  
  27. public static double getBalance() {
  28. return balance;
  29. }
  30.  
  31. public static void setBalance(double balance) {
  32. BankAccount.balance = balance;
  33. }
  34.  
  35.  
  36. void deposit(double amount) {
  37. balance += amount;
  38. }
  39.  
  40. double getInterest(int year) {
  41. return BankAccount.interestRate * year * this.balance;
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement