Class 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
    • 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
      void calculateMonthlyInterest()
      uses yearly interest rate and balance to determine dollar amount of interest earned monthly
      side effect: balance is updated.
      void deposit​(double amount)
      deposit will increase the account balance by the amount provided by the parameter balance is updated
      double getMonthlyInterest()  
      java.lang.String toString()  
      void withdraw​(double amount)
      will decrease the account balance by the amount provided by the parameter balance is updated
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • SavingsAccount

        public SavingsAccount​(int accountNum,
                              double initialBalance,
                              double yearlyInterest)
        SavingsAccount constructor
        Parameters:
        accountNum - the account number
        initialBalance - the initial balance
        yearlyInterest - the annual rate of compound interest
    • 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:
        deposit in class AbstractAccount
        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:
        withdraw in class AbstractAccount
        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:
        toString in class AbstractAccount
        Returns:
        formatted representation of account