Advertisement
Guest User

Untitled

a guest
Apr 18th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. //Sarah Mottram
  2. public class Savings extends Account
  3. {
  4. double interest = 1;
  5. long timeA;
  6. boolean exists;
  7. public Savings(int overdraftPreference)
  8. {
  9. super(overdraftPreference, "Savings");
  10. timeA = System.currentTimeMillis();
  11. }
  12. public void setInterest(double interest)
  13. {
  14. this.interest = interest;
  15. }
  16. public boolean withdraw(double with)
  17. {
  18. long checkInt = System.currentTimeMillis() - timeA;
  19. if(checkInt >60000)
  20. {
  21. for(int i = (int) (checkInt%60000); i > 0; i--)
  22. {
  23. super.deposit((super.getTrueValue()*(interest/100)));
  24. }
  25. timeA = System.currentTimeMillis();
  26. }
  27. return super.withdraw(with);
  28. }
  29. public boolean transfer(double trans, Account a)
  30. {
  31. long checkInt = System.currentTimeMillis() - timeA;
  32. if(checkInt >60000)
  33. {
  34. for(int i = (int) (checkInt%60000); i > 0; i--)
  35. {
  36. super.deposit((super.getTrueValue()*(interest/100)));
  37. }
  38. timeA = System.currentTimeMillis();
  39. }
  40. return super.transfer(trans,a);
  41. }
  42. public double getTrueValue() //THIS RETURNS A DOUBLE AND SHOULD BE USED FOR MATH STUFF
  43. {
  44. long checkInt = System.currentTimeMillis() - timeA;
  45. if(checkInt >60000)
  46. {
  47. for(int i = (int) (checkInt%60000); i > 0; i--)
  48. {
  49. super.deposit((super.getTrueValue()*(interest/100)));
  50. }
  51. timeA = System.currentTimeMillis();
  52. }
  53. return super.getTrueValue();
  54. }
  55. public String getValue() //THIS RETURNS A STRING AND SHOULD BE USED FOR WHEN YOU WANT THE MONEY VALUE WITH 2 DECIMAL PLACES
  56. {
  57. long checkInt = System.currentTimeMillis() - timeA;
  58. if(checkInt >60000)
  59. {
  60. for(int i = (int) (checkInt%60000); i > 0; i--)
  61. {
  62. super.deposit((super.getTrueValue()*(interest/100)));
  63. }
  64. timeA = System.currentTimeMillis();
  65. }
  66. return super.getValue();
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement