Monom - Shir-Av/Ex1 GitHub Wiki
This class implements the interface function and represents a simple "Monom" of shape a*x^b, where a is a real number and b is an integer.
Constructors and methods implemented:
- public Monom(double a, int b): Constructor that initialize a as the coefficient and b as the power of the Monom.
- public Monom(Monom ot): Copy constructor.
- public Monom(String s): Initialize Monom from a given string.
- public Monom derivative(): returns the derivative monom of a given monom.
- public double f(double x): calculates the value of f at a given point 'x'.
- public boolean isZero(): Returns true if and only if the Monom is logically equals to 0.
- public void add(Monom m): adds a monom to a given monom of the same power.
- public void subtract(Monom m): Subtract a monom to from a given monom of the same power.
- public void multiply(Monom d): Multiply d with this Monom.
- public boolean equals(Object obj): returns true if tow monoms are logically equal.
- public String toString(): Print the Monom as "ax^b". If the power is 1 it returns "ax". If the power is 0 it returns "a". And if the coefficient is zero it returns "0".
- public function initFromString(String s): Returns a function from a given string.
- public function copy(): Returns a function with a deep copy of this Monom.