
/**
 * AmortizedLoan provides a concrete implementation of a Loan object.
 */
public class AmortizedLoan extends Loan
{
    /**
     * This constructor simply calls the contructor from the Loan class.
     */
    public AmortizedLoan(String name, double rate, int years, double amount)
    {
        super(name, rate, years, amount);
    }

    /* Return the loan type as a string */
    public String toString()
    {
        return "Full Amortized Loan";
    }

    /**
     * Calculate the monthly payment for a AmortizedLoan
     */
    public void calcMonthlyPayment()
    {
        double adjMonthlyRate = m_interestRate / 100.0 / 12.0;
        double lengthInMonths = m_length * 12;
        double n = Math.pow(1 + adjMonthlyRate, lengthInMonths);
        m_monthlyPayment = (m_principal * adjMonthlyRate * n) / (n - 1);
    }
}
