Advertisement
Guest User

Untitled

a guest
Feb 11th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. package assignment8;
  2.  
  3. /**
  4. * Created by codden on 28/01/16.
  5. */
  6. public class BSU extends SavingsAccount {
  7. private double max;
  8. private double temp;
  9.  
  10. public BSU(double interestRate, double max) {
  11. super(interestRate);
  12. this.max = max;
  13. this.temp = 0;
  14. }
  15.  
  16. @Override
  17. public void deposit (double amount){
  18. if (this.temp + amount <= max) {
  19. this.temp += amount;
  20. super.deposit(amount);
  21. } else {
  22. throw new IllegalStateException("Gå og dø");
  23. }
  24. }
  25.  
  26. @Override
  27. public void withdraw(double amount){
  28. if (amount < temp) {
  29. temp -= amount;
  30. super.withdraw(amount);
  31. } else {
  32. throw new IllegalStateException();
  33. }
  34. }
  35.  
  36. public double getTaxDeduction(){
  37. double temp2 = temp;
  38. temp = 0;
  39. return temp2 * 0.2;
  40. }
  41.  
  42.  
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement