Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Sarah Mottram
- public class Savings extends Account
- {
- double interest = 1;
- long timeA;
- boolean exists;
- public Savings(int overdraftPreference)
- {
- super(overdraftPreference, "Savings");
- timeA = System.currentTimeMillis();
- }
- public void setInterest(double interest)
- {
- this.interest = interest;
- }
- public boolean withdraw(double with)
- {
- long checkInt = System.currentTimeMillis() - timeA;
- if(checkInt >60000)
- {
- for(int i = (int) (checkInt%60000); i > 0; i--)
- {
- super.deposit((super.getTrueValue()*(interest/100)));
- }
- timeA = System.currentTimeMillis();
- }
- return super.withdraw(with);
- }
- public boolean transfer(double trans, Account a)
- {
- long checkInt = System.currentTimeMillis() - timeA;
- if(checkInt >60000)
- {
- for(int i = (int) (checkInt%60000); i > 0; i--)
- {
- super.deposit((super.getTrueValue()*(interest/100)));
- }
- timeA = System.currentTimeMillis();
- }
- return super.transfer(trans,a);
- }
- public double getTrueValue() //THIS RETURNS A DOUBLE AND SHOULD BE USED FOR MATH STUFF
- {
- long checkInt = System.currentTimeMillis() - timeA;
- if(checkInt >60000)
- {
- for(int i = (int) (checkInt%60000); i > 0; i--)
- {
- super.deposit((super.getTrueValue()*(interest/100)));
- }
- timeA = System.currentTimeMillis();
- }
- return super.getTrueValue();
- }
- public String getValue() //THIS RETURNS A STRING AND SHOULD BE USED FOR WHEN YOU WANT THE MONEY VALUE WITH 2 DECIMAL PLACES
- {
- long checkInt = System.currentTimeMillis() - timeA;
- if(checkInt >60000)
- {
- for(int i = (int) (checkInt%60000); i > 0; i--)
- {
- super.deposit((super.getTrueValue()*(interest/100)));
- }
- timeA = System.currentTimeMillis();
- }
- return super.getValue();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement