Package BankAccountPkg
Class SavingsAccount
- java.lang.Object
-
- BankAccountPkg.AbstractAccount
-
- BankAccountPkg.SavingsAccount
-
public class SavingsAccount extends AbstractAccount
This class implements a simple model of a savings account- Version:
- 1.1
- Author:
- George Kriger
- See Also:
AbstractAccount
-
-
Field Summary
-
Fields inherited from class BankAccountPkg.AbstractAccount
accountNum, balance
-
-
Constructor Summary
Constructors Constructor Description SavingsAccount(int accountNum, double initialBalance, double yearlyInterest)SavingsAccount constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcalculateMonthlyInterest()uses yearly interest rate and balance to determine dollar amount of interest earned monthly
side effect: balance is updated.voiddeposit(double amount)deposit will increase the account balance by the amount provided by the parameter balance is updateddoublegetMonthlyInterest()java.lang.StringtoString()voidwithdraw(double amount)will decrease the account balance by the amount provided by the parameter balance is updated-
Methods inherited from class BankAccountPkg.AbstractAccount
getBalance
-
-
-
-
Method Detail
-
calculateMonthlyInterest
public void calculateMonthlyInterest()
uses yearly interest rate and balance to determine dollar amount of interest earned monthly
side effect: balance is updated. Be sure to run only once per month
-
deposit
public void deposit(double amount)
deposit will increase the account balance by the amount provided by the parameter balance is updated- Specified by:
depositin classAbstractAccount- Parameters:
amount- how much to deposit into the account
-
withdraw
public void withdraw(double amount)
will decrease the account balance by the amount provided by the parameter balance is updated- Specified by:
withdrawin classAbstractAccount- Parameters:
amount- how much to withdraw from the account
-
getMonthlyInterest
public double getMonthlyInterest()
- Returns:
- the dollar amount of interest earned this month
be sure to invoke calculateMonthlyInterest() first.
-
toString
public java.lang.String toString()
- Specified by:
toStringin classAbstractAccount- Returns:
- formatted representation of account
-
-