public class MPro
extends java.lang.Object
AMORT_MIN
,AMORT_MAX
], and
an interest rate percent in [0, INTEREST_MAX
].Modifier and Type | Field and Description |
---|---|
static int |
AMORT_MAX
The maximum amortization period allowed.
|
static int |
AMORT_MIN
The minimum amortization period allowed.
|
static double |
EPSILON
A small number that sets the resolution in this class such that any
real number less than it in absolute value is deemed to be zero.
|
static int |
INTEREST_MAX
The maximum interest rate percent allowed.
|
Constructor and Description |
---|
MPro()
Construct an instance having zero principle,
AMORT_MIN amortization, and zero interest. |
MPro(java.lang.String p,
java.lang.String i)
Construct an instance having the given principle and interest and
a default amortization as set in
AMORT_MAX |
MPro(java.lang.String p,
java.lang.String a,
java.lang.String i)
Construct an instance having the given principle, amortization, and interest.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
computePayment(java.lang.String format)
Compute the monthly payment.
|
boolean |
equals(MPro other)
Determine if this instance is equal to the given instance.
|
java.lang.String |
getAmortization()
The amortization accessor.
|
java.lang.String |
getInterest()
The interest accessor.
|
java.lang.String |
getPrinciple()
The principle accessor.
|
java.lang.String |
outstandingAfter(int years,
java.lang.String format)
Compute the balance that is still outstanding after the given number of years.
|
void |
setAmortization(java.lang.String a)
The amortization mutator.
|
void |
setInterest(java.lang.String i)
The interest mutator.
|
void |
setPrinciple(java.lang.String p)
The principle mutator.
|
java.lang.String |
toString()
Return a textual representation of this instance.
|
public static final int AMORT_MIN
public static final int AMORT_MAX
public static final int INTEREST_MAX
public static final double EPSILON
public MPro(java.lang.String p, java.lang.String a, java.lang.String i)
p
- the principle amounta
- the amortization periodi
- the ratejava.lang.RuntimeException
- if the parameters are not numeric, if p is not positive, a is
not in [AMORT_MIN
,AMORT_MAX
], or i is not in [0, INTEREST_MAX
].public MPro(java.lang.String p, java.lang.String i)
AMORT_MAX
p
- the principle amounti
- the ratejava.lang.RuntimeException
- if the parameters are not numeric or if p is not positive or i
is not in [0, INTEREST_MAX
].public MPro()
AMORT_MIN
amortization, and zero interest.public java.lang.String getPrinciple()
public java.lang.String getAmortization()
public java.lang.String getInterest()
public void setPrinciple(java.lang.String p)
p
- the principle amountjava.lang.RuntimeException
- if p is not numeric or not positive.public void setAmortization(java.lang.String a)
public void setInterest(java.lang.String i)
i
- the ratejava.lang.RuntimeException
- if i is not numeric or not in [0, INTEREST_MAX
].public java.lang.String computePayment(java.lang.String format)
format
- the format specifier.public java.lang.String outstandingAfter(int years, java.lang.String format)
years
- the number of years since the mortgage started.format
- the format specifier.public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(MPro other)
EPSILON
.other
- the given instance