aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Week7/src/polynomial/Polynomial.java3
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();