Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
public class BankAccountComp {
private InterestAccount acct;
private int accountAge;
//Constructors
public BankAccountComp () {
this.acct = new InterestAccount(0, 0.06);
this.accountAge = 0;
}
public BankAccountComp (double startingBal) {
this.acct = new InterestAccount(startingBal, 0.06);
this.accountAge = 0;
}
//Getters and Setters
public int getAccountAge () { return this.accountAge; }
public void setAccountAge (int a) { this.accountAge = a; }
public double getBalance () { return acct.getBalance(); }
//Other member functions
/**
* Given a double, add that amount to the balance
* @param sum The amount of money being deposited into the account
* @return The balance after the deposit
*/
public double deposit (double sum) {
acct.setBalance(acct.getBalance() + sum);
return acct.getBalance();
}
/**
* Given a double, add that ammount to the balance
* @param sum The amount of money being withdrawn from the account
* @return The balance after the withdrawal
*/
public double withdraw (double sum) {
acct.setBalance(acct.getBalance() - sum);
return acct.getBalance();
}
/**
* Accrue account for one year
* @return The balance of the account after accrual
*/
public double accrue () {
accountAge++;
return acct.accrue();
}
/**
* Given a number of years, accrue account over years
* @param y The number of years to accrue over
* @return The balance of the account after accrual
*/
public double accrueYears (int y) {
accountAge += y;
return acct.accrueYears(y);
}
}