Polynom Class - Shir-Av/Ex1 GitHub Wiki
This class implements the interface Polynom_able. represents a Polynom of shape a_1x^b_1+a_2x^b_2+….+a_nx^b_n and is composed of ArrayList of type monoms.
Constructors and methods implemented:
- public Polynom(String s): init a Polynom from a String such as: "x^2", "-2x^2+44".
- public double f(double x): calculates the value of f at a given point 'x'.
- public void add(Monom m1): adds a given monom to a polynom, the result saved on this Polynom.
- public void add (polynom p) – function that adds two polynoms together.
- public void subtract(Monom p1): subtracts 2 polynoms by multiplying p1 by (-1) and that using the add method on the givan polynom.
- public void multiply(Monom m1): Multiplies the polynom with a given monom using iterator.
- public void multiply(Polynom_able p1): multiplies tow polynoms by using iterator and the multiply(Monom m1) method.
- public boolean equals(Object obj): Returns true if the tow polynoms are logically equal to this Polynom.
- public boolean isZero(): returns true if the polynom equals zero
- public double root(double x0, double x1, double eps): Compute a value x' (x0<=x'<=x1) for with |f(x')| < eps.
- public Polynom_able copy(): Returns deep copy of this Polynom.
- public Polynom_able derivative(): Returns new Polynom_able that is this Polynom derivative.
- public double area(double x0, double x1, double eps): Computes Reimann's Integral between x0 and x1 with eps steps.
- public Iterator iteretor(): Returns Monom iterator.
- public String toString(): returns a string of a polynom for ex: "a1x^b1+a2x^b2..anx^bn".
- public function initFromString(String s): Returns function type object from a given string.