Class AbstractPoly

java.lang.Object
it.unimi.di.prog2.h18.AbstractPoly
All Implemented Interfaces:
Poly, Iterable<Poly.Term>
Direct Known Subclasses:
DensePoly, SparsePoly

public abstract class AbstractPoly extends Object implements Poly
A partial implementation of non-zero Polys.
  • Field Details

    • degree

      private final int degree
      The degree of the polynomial.
  • Constructor Details

    • AbstractPoly

      protected AbstractPoly(int degree)
      Initializes this to be the a polynomial with given degree.
      Parameters:
      degree - the degree.
      Throws:
      IllegalArgumentException - if n is not positive.
  • Method Details

    • isZero

      public boolean isZero()
      Description copied from interface: Poly
      Checks whether this polynomial is the zero polynomial.
      Specified by:
      isZero in interface Poly
      Returns:
      true if this polynomial is the zero polynomial, false otherwise.
    • degree

      public int degree()
      Description copied from interface: Poly
      Returns the degree of this polynomial.
      Specified by:
      degree in interface Poly
      Returns:
      the largest exponent with a non-zero coefficient.
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object