diff options
author | Camil Staps | 2015-03-17 19:19:07 +0100 |
---|---|---|
committer | Camil Staps | 2015-03-17 19:19:07 +0100 |
commit | d854e8bc5f45eb8c1c7fa0277744247fcfe164fa (patch) | |
tree | 127412048373f28b61a316805cc53da5db68db6c | |
parent | Added javadoc (diff) |
Minor fix in Polynomial.plus(Term) for empty terms
-rw-r--r-- | Week7/src/polynomial/Polynomial.java | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Week7/src/polynomial/Polynomial.java b/Week7/src/polynomial/Polynomial.java index 40c1448..86f060b 100644 --- a/Week7/src/polynomial/Polynomial.java +++ b/Week7/src/polynomial/Polynomial.java @@ -101,6 +101,9 @@ public class Polynomial { * @param t the term to add */ private void plus(Term t) { + if (t.getCoef() == 0) + return; + Iterator<Term> iter = terms.iterator(); while (iter.hasNext()) { Term this_t = iter.next(); |